V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
iOS 开发实用技术导航
NSHipster 中文版
http://nshipster.cn/
cocos2d 开源 2D 游戏引擎
http://www.cocos2d-iphone.org/
CocoaPods
http://cocoapods.org/
Google Analytics for Mobile 统计解决方案
http://code.google.com/mobile/analytics/
WWDC
https://developer.apple.com/wwdc/
Design Guides and Resources
https://developer.apple.com/design/
Transcripts of WWDC sessions
http://asciiwwdc.com
Cocoa with Love
http://cocoawithlove.com/
Cocoa Dev Central
http://cocoadevcentral.com/
NSHipster
http://nshipster.com/
Style Guides
Google Objective-C Style Guide
NYTimes Objective-C Style Guide
Useful Tools and Services
Charles Web Debugging Proxy
Smore
kengsir
V2EX  ›  iDev

浪起来的头像

  •  
  •   kengsir · 2016-09-06 08:50:55 +08:00 · 3131 次点击
    这是一个创建于 2797 天前的主题,其中的信息可能已经有所发展或是发生改变。

    #DEMO 下载 下载链接

    效果演示

    images

    你需要知道的

    CADisplayLink

    简单的说就是一定时器,其根本利用刷帧和屏幕频率一样来重绘渲染页面. 其创建方式:

    CADisplayLink *timer = [CADisplayLink displayLinkWithTarget:self selector:@selector(wave)];
    [timer addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes];
    

    CAShapeLayer

    CALayer 的子类,通常结合 CGPath 来绘制图形. 其创建方式:

    CAShapeLayer *Layer = [CAShapeLayer layer];
    Layer.frame =  self.bounds;
    Layer.fillColor = self.realWaveColor.CGColor;
    Layer...等属性
    [self.view.layer addSublayer:Layer];
    

    其优点

    • 渲染效率高渲染快速。 CAShapeLayer 使用了硬件加速,绘制同一图形会比用 Core Graphics 快很多。
    • 高效使用内存。一个 CAShapeLayer 不需要像普通 CALayer 一样创建一个寄宿图形,所以无论有多大,都不会占用太多的内存。
    • 不会被图层边界剪裁掉。一个 CAShapeLayer 可以在边界之外绘制。你的图层路径不会像在使用 Core Graphics 的普通 CALayer 一样被剪裁掉。
    • 不会出现像素化。当你给 CAShapeLayer 做 3D 变换时,它不像一个有寄宿图的普通图层一样变得像素化。

    三角函数

    images

    images

    思路实现

    UIView --> 2 个 CAShapeLayer --> imageView.frame.orgin.y 调整

    主要代码实现

    头文件

    images

    实现

    images

    调用

    images

    12 条回复    2016-09-22 09:54:43 +08:00
    ELLIA
        1
    ELLIA  
       2016-09-06 09:06:18 +08:00
    这个创意很不错!点个赞!
    designer
        2
    designer  
       2016-09-06 09:12:00 +08:00 via iPhone
    很棒!
    Olive
        3
    Olive  
       2016-09-06 09:31:11 +08:00
    好看,但头晕
    badcode
        4
    badcode  
       2016-09-06 09:43:57 +08:00
    hqdmy
        5
    hqdmy  
       2016-09-06 09:50:58 +08:00
    够浪!
    megatron
        6
    megatron  
       2016-09-06 09:53:37 +08:00
    -好像发错节点了?
    -头像是一艘小船就非常有意思了。
    kengsir
        7
    kengsir  
    OP
       2016-09-06 10:21:22 +08:00
    demo 下载均有原文出处,感兴趣的可以到 github 观摩,或者 code4app 也有其他好玩的东西,都是学习的地方 http://www.code4app.com
    jiane
        8
    jiane  
       2016-09-06 17:18:40 +08:00
    有创意。。
    hei1000
        9
    hei1000  
       2016-09-06 20:08:02 +08:00
    啊,代码字体受不了 T_T
    free9fw
        10
    free9fw  
       2016-09-07 00:02:47 +08:00
    代码字体太丑
    newkengsir
        11
    newkengsir  
       2016-09-21 09:21:03 +08:00
    - -
    newkengsir
        12
    newkengsir  
       2016-09-22 09:54:43 +08:00
    哈哈哈 好的建议不
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2280 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 03:31 · PVG 11:31 · LAX 20:31 · JFK 23:31
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.