Loading

IOS:个人笔记|UI_渐变动画

 这个挺简单的,就一个方法,弄清楚几个参数的作用就行。直接上例子

 1 //方式一
 2     [UIView animateWithDuration:2.0 animations:^{
 3         CGRect frame=self.imageView.frame;
 4         frame.origin.y-=50;
 5         self.imageView.frame=frame;
 6     }];
 7     //方式二
 8     [UIView animateWithDuration:2.0 animations:^{
 9         CGRect frame=self.imageView.frame;
10         frame.origin.y-=50;
11         self.imageView.frame=frame;
12     } completion:^(BOOL finished) {
13         NSLog(@"动画结束");
14     }];
15     
16     /*参数说明
17      动画执行的时间,延迟几秒开始动画,执行的方式,要完成的动画,完成动画要做的事
18      
19      执行的方式点进去有很多,目前我们需要知道4种
20        UIViewAnimationCurveEaseInOut,         // 开始结束比较慢,中间比较快
21        UIViewAnimationCurveEaseIn,            // 开始比较慢
22        UIViewAnimationCurveEaseOut,           // 结束比较慢
23        UIViewAnimationCurveLinear,           //线性,匀速
24      **/
25     [UIView animateWithDuration:2.0 delay:2.0 options:UIViewAnimationCurveEaseInOut animations:^{
26         CGRect frame=self.imageView.frame;
27         frame.origin.y-=50;
28         self.imageView.frame=frame;
29     } completion:^(BOOL finished) {
30         NSLog(@"动画结束");
31     }];
32    
33  //缩放,其实就是改变frame大小
34     [UIView  animateWithDuration:2.0 delay:2.0 options:UIViewAnimationOptionCurveEaseIn animations:^{
35         CGRect frame=self.imageView.frame;
36         frame.size=CGSizeMake(100100);
37         self.imageView.frame=frame;
38         
39     } completion:^(BOOL finished) {
40         NSLog(@"动画结束");
41     }];
42     //透明度
43     [UIView animateWithDuration:1.0 delay:1.0 options:UIViewAnimationOptionCurveEaseIn animations:^{
44         self.imageView.alpha-=0.5;
45     } completion:^(BOOL finished) {
46         self.imageView.alpha+=0.5;
47         NSLog(@"动画结束");
48     }];

 

posted @ 2020-09-30 16:52  DDD-SagerKing  阅读(199)  评论(0编辑  收藏  举报