ios几行代码搞定按钮点击水波纹效果

1,243 阅读1分钟

不知道为什么就是想上个效果图:

test.gif
代码如下:

    CATransition *animation = [CATransition animation];
    animation.type =@"rippleEffect";
    [animation setDuration:1.5];
    [animation setRepeatCount:1.0];
    [button.layer addAnimation:animation forKey:@"s rippleEffect"];

Duration :设置时间,多久完成动画,播放速率 原文:

@property CFTimeInterval duration;

/* The rate of the layer. Used to scale parent time to local time, e.g.

 * if rate is 2, local time progresses twice as fast as parent time.

 * Defaults to 1. */

RepeatCount 动画执行次数,原文:

@property float repeatCount;

/* The repeat duration of the object. Defaults to 0. */