首页 > 学院 > 开发设计 > 正文

水纹波浪效果动画

2019-11-09 16:53:26
字体:
来源:转载
供稿:网友

github:https://github.com/potato512/SYAnimation

效果图:

示例代码见"github:https://github.com/potato512/SYAnimation"中的"SYWaterAnimationView"类。

使用:

// 使用方法1SYWaterAnimationView *waterView = [[SYWaterAnimationView alloc] initWithFrame:CGRectMake(10.0, 120.0, (self.view.frame.size.width - 10.0 * 2), 100.0) waveColor:[UIColor colorWithRed:73/255.0 green:142/255.0 blue:178/255.0 alpha:0.5] waterColor:[UIColor colorWithRed:73/255.0 green:142/255.0 blue:178/255.0 alpha:0.5]];waterView.backgroundColor = [UIColor colorWithWhite:0.2 alpha:0.3];waterView.tag = 1000;[self.view addSubview:waterView];
// 使用方法2SYWaterAnimationView *waterView2 = [[SYWaterAnimationView alloc] initWithFrame:CGRectMake(10.0, 230.0, (self.view.frame.size.width - 10.0 * 2), 100.0)];waterView2.backgroundColor = [UIColor colorWithWhite:0.2 alpha:0.3];waterView2.waterColor = [UIColor redColor];waterView2.waveColor = [UIColor greenColor];waterView2.waveAmplitude = 11.0;waterView2.waveSpeed = 0.05;waterView2.wavePeriod = (M_PI) / self.view.frame.size.width;waterView2.waveWidth = self.view.frame.size.width;waterView2.waveCurrentHeight = 20.0;waterView2.tag = 1001;[self.view addSubview:waterView2];特别注意,需要在视图控制器被释放时释放动画资源,避免造成内存泄露

- (void)viewWillDisappear:(BOOL)animated{    [super viewWillDisappear:animated];        SYWaterAnimationView *waterView = (SYWaterAnimationView *)[self.view viewWithTag:1000];    [waterView animationWaterInvalidate];        waterView = (SYWaterAnimationView *)[self.view viewWithTag:1001];    [waterView animationWaterInvalidate];}


上一篇:VLC的block_t

下一篇:乱码问题解决方法

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表