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 · Sep 6, 2016 · 4662 views
    This topic created in 3713 days ago, the information mentioned may be changed or developed.

    #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 replies  •  2016-09-22 09:54:43 +08:00
    ELLIA
    ELLIA
    Sep 6, 2016
    1
    这个创意很不错!点个赞!
    designer
    designer
    Sep 6, 2016 via iPhone
    2
    很棒!
    Olive
    Olive
    Sep 6, 2016
    3
    好看,但头晕
    hqdmy
    hqdmy
    Sep 6, 2016
    5
    够浪!
    megatron
    megatron
    Sep 6, 2016
    6
    -好像发错节点了?
    -头像是一艘小船就非常有意思了。
    kengsir
    kengsir
    OP
    Sep 6, 2016
    7
    demo 下载均有原文出处,感兴趣的可以到 github 观摩,或者 code4app 也有其他好玩的东西,都是学习的地方 http://www.code4app.com
    jiane
    jiane
    Sep 6, 2016
    8
    有创意。。
    hei1000
    hei1000
    Sep 6, 2016
    9
    啊,代码字体受不了 T_T
    free9fw
    free9fw
    Sep 7, 2016
    10
    代码字体太丑
    newkengsir
    newkengsir
    Sep 21, 2016
    11
    - -
    newkengsir
    newkengsir
    Sep 22, 2016
    12
    哈哈哈 好的建议不
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   3698 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 46ms · UTC 05:21 · PVG 13:21 · LAX 21:21 · JFK 00:21
    ♥ Do have faith in what you're doing.