UI Animation 动画效果

  1 - (void)buttonClicked:(UIButton *)button
  2 {
  3     // UIView 动画
  4     // 1.最简单的动画实现
  5     // 参数1:动画执行一次需要的时间
  6     // 参数2:动画执行的内容(写动画执行的结果)
  7 //    [UIView animateWithDuration:10.0 animations:^{
  8 //        button.alpha = 0.38;
  9 //        button.backgroundColor = [UIColor blueColor];
 10 //        button.frame = CGRectMake(0, 0, 320, 100);
 11 //    }];
 12
 13
 14
 15
 16     // 参数3:动画执行结束后 要执行的代码
 17 //    [UIView animateWithDuration:1.f animations:^{
 18 //
 19 //        // 对动画本身设置
 20 //
 21 //        // 可以给动画一个还原效果
 22 //        [UIView setAnimationRepeatAutoreverses:YES];
 23 //        // 动画重复的次数
 24 //        [UIView setAnimationRepeatCount:1.25];
 25 //        // 动画延迟几秒执行
 26 //       // [UIView setAnimationDelay:1.0];
 27 //        // 动画运行的速度曲线
 28 //        [UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
 29 //
 30 //        button.backgroundColor = [UIColor blueColor];
 31 //        button.bounds = CGRectMake(0, 0, 200, 200);
 32 //    } completion:^(BOOL finished) {
 33 //        NSLog(@"动画完毕");
 34 //    }];
 35
 36
 37
 38     // 3.
 39
 40     // 参数3:动画的选项 在这里一般写 速度曲线
 41 //    [UIView animateKeyframesWithDuration:1.f delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
 42 //        button.frame = CGRectMake(0, 0, 200, 200);
 43 //    } completion:nil];
 44
 45
 46
 47     //4.
 48
 49 //    [UIView animateWithDuration:1.f delay:0 usingSpringWithDamping:0.05 initialSpringVelocity:0.4 options:UIViewAnimationOptionCurveEaseIn animations:^{
 50 //        button.frame = CGRectMake(0, 0, 200, 200);
 51 //    } completion:nil];
 52
 53
 54
 55     // transition动画
 56
 57 //    [UIView transitionWithView:button duration:1.f options:UIViewAnimationOptionTransitionCurlDown animations:^{
 58 //        button.frame = CGRectMake(0, 0, 200, 200);
 59 //    } completion:nil];
 60
 61
 62
 63     // 把第一个视图移除 把第二个视图 添加到父视图上
 64
 65 //    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];
 66 //    view.backgroundColor = [UIColor blueColor];
 67 //    // 参数1;要移除的view
 68 //    // 参数2:要添加的view
 69 //    [UIView transitionFromView:button toView:view duration:1.f options:UIViewAnimationOptionTransitionCurlUp completion:^(BOOL finished) {
 70 //
 71 //    }];
 72
 73
 74
 75     // CAAnimation layer层动画
 76
 77     // CAPropertyAnimation 是一个抽象类
 78     // 1. CABasicAnimation 的使用
 79
 80 //    CABasicAnimation *animation1 = [CABasicAnimation animationWithKeyPath:@"transform.scale.y"];
 81 //    // 从什么状态开始放大
 82 //    animation1.fromValue = [NSNumber numberWithInt:1];
 83 //    // 到什么状态结束
 84 //    animation1.toValue = [NSNumber numberWithInt:3];
 85 //    // 动画执行的时间
 86 //    animation1.duration = 1.f;
 87 //    // 是否有一个恢复
 88 //    animation1.autoreverses = YES;
 89 //    animation1.repeatCount = NSIntegerMax;
 90 //
 91 //
 92 //    CABasicAnimation *animation2 = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
 93 //
 94 //    // 从什么状态开始放大
 95 //    animation2.fromValue = [NSNumber numberWithInt:1];
 96 //    // 到什么状态结束
 97 //    animation2.toValue = [NSNumber numberWithInt:M_PI * 2];
 98 //    // 动画执行的时间
 99 //    animation2.duration = 2.f;
100 //    // 是否有一个恢复
101 ////    animation2.autoreverses = YES;
102 //    animation2.repeatCount = NSIntegerMax;
103 //
104 //
105 //
106 //    // 组动画 将几个动画组合到一起 同时执行
107 //
108 //    CAAnimationGroup *group = [CAAnimationGroup animation];
109 //    group.animations = @[animation1,animation2];
110 //    // 将动画 添加到组动画之后 每个动画自己的设置将失效
111 //    group.duration = 3.f;
112 //    group.autoreverses = YES;
113 //    group.repeatCount = NSIntegerMax;
114 //
115 //    [button.layer addAnimation:group forKey:@"111"];
116 //
117 //
118 //
119 //    [button.layer addAnimation:animation2 forKey:@"111"];
120
121
122
123
124 //    // 关键帧动画
125 //    CAKeyframeAnimation *keyFrameAni = [CAKeyframeAnimation animationWithKeyPath:@"position"];
126 //
127 //    // 产生一个路径
128 //    CGMutablePathRef path = CGPathCreateMutable();
129 //    // 设定一个初始点
130 //    CGPathMoveToPoint(path, nil, 100, 100);
131 //
132 //    // 添加一个路过的点(添加一条直线的路径)
133 //    CGPathAddLineToPoint(path, NULL, 200, 100);
134 //    CGPathAddLineToPoint(path, NULL, 300, 0);
135 //    CGPathAddLineToPoint(path, NULL, 10, 200);
136 //    CGPathAddLineToPoint(path, NULL, 30, 0);
137 //    CGPathAddLineToPoint(path, NULL, 150, 40);
138 //    CGPathAddLineToPoint(path, NULL, 300, 0);
139 //
140 //
141 //    // 添加一条曲线路径
142 //    CGPathAddCurveToPoint(path, NULL, 10, 20, 100, 300, 150, 100);
143 //    CGPathAddCurveToPoint(path, NULL, 100, 150, 100, 0, 150, 100);
144 //    CGPathAddCurveToPoint(path, NULL, 120, 230, 105, 542, 10, 10);
145 //
146 //    // 设置路径信息
147 //    [keyFrameAni setPath:path];
148 //    // 设置执行时间
149 //    [keyFrameAni setDuration:5.f];
150 //
151 //    [button.layer addAnimation:keyFrameAni forKey:@"222"];
152
153
154
155       // 过渡 变形
156 //    CATransition *transition = [CATransition animation];
157 //
158 //    // 过渡动画CATransition 依靠type/subType改变动画效果
159 //    transition.duration = 2.f;
160 //
161 //    // 动画类型
162 //    //[transition setType:kCATransitionMoveIn];
163 //    [transition setType:@"cameraIrisHollowClose"];
164 //    // 动画方向
165 //    [transition setSubtype:kCATransitionFromLeft];
166 //
167 //    [button.layer addAnimation:transition forKey:@"333"];
168 }  
时间: 2024-08-27 08:55:48

UI Animation 动画效果的相关文章

android中xml设置Animation动画效果详解

在 android 中, Animation 动画效果的实现可以通过两种方式进行实现,一种是 tweened animation 渐变动画,另一种是 frame by frame animation 画面转换动画. tweened animation 渐变动画有以下两种类型: 1.alpha 渐变透明度动画效果 2.scale 渐变尺寸伸缩动画效果 frame by frame animation 画面转换动画有以下两种类型: 1.translate 画面转换位置移动动画效果 2.rotate

android中设置Animation 动画效果

在 Android 中, Animation 动画效果的实现可以通过两种方式进行实现,一种是 tweened animation 渐变动画,另一种是 frame by frame animation 画面转换动画,接下来eoe进行讲解. tweened animation 渐变动画有以下两种类型: 1.alpha   渐变透明度动画效果 2.scale   渐变尺寸伸缩动画效果 frame by frame animation 画面转换动画有以下两种类型: 1.translate  画面转换位置

android animation动画效果的两种实现方式

animation动画效果两种实现方式 注:此例为AlphaAnimation效果,至于其他效果,换一下对象即可. 1..java文件 代码控制 添加并且开始animation动画 //添加动画效果 AlphaAnimation animation = new AlphaAnimation(0.3f, 1.0f); //设置次效果的持续时间 animation.setDuration(2000); //设置动画的监听事件 animation.setAnimationListener(new An

Core Animation 动画效果介绍

在开始之前呢,先了解一下UIView和CALayer大体的区别(重点列举了以下四点): UIView继承自 UIResponder,因此UIView 可以处理响应事件,而CALayer继承自NSObject,所以它只是负责内容的创建,绘制. UIView负责对内容的管理,而CALayer则是对内容的绘制 UIView中有关位置的属性只有frame.bounds.center,而CALayer除了具备这些属性之外还有anchorPoint.position. 通过修改CALayer可以实现UIVi

Android学习——Animation动画效果

1.Android动画模式: 1>tweened animation: 渐变动画: 2>frame by frame: 画面转换动画. 2.Android的Animation动画由四种类型组成: XML alpha 渐变透明度动画效果 scale 渐变尺寸伸缩动画效果 translate 画面转换位置移动动画效果 rotate 画面转移旋转动画效果 Java代码 AlphaAnimation 渐变透明度动画效果 ScaleAnimation 渐变尺寸伸缩动画效果 TranslateAnimat

(四)Android动画开发---Animation动画效果详解

Android 使用Animation的具体操作方法我们将会在这篇文章中做一个详细的介绍.大家可以通过这里举出的代码进行解读,并从中了解到相关操作技巧,方便我们将来开发应用,并且加深对这一操作系统的理解程度. 在Android中,分别可以在xml中定义Animation,也可以在程序代码中定义. 动画类型 Android的animation由四种类型组成 XML中 alpha 渐变透明度动画效果 scale 渐变尺寸伸缩动画效果 translate 画面转换位置移动动画效果 rotate 画面转

Animation动画效果简单汇总

------------案例结构很复杂一步步来------------ 1.activity_main.xml(首先看启动界面布局文件,里面有2个button) <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width=&q

Android animator Animation动画效果详解

Android的animation由四种类型组成 XML中 alpha 渐变透明度动画效果 scale 渐变尺寸伸缩动画效果 translate 画面转换位置移动动画效果 rotate 画面转移旋转动画效果 JavaCode中 AlphaAnimation 渐变透明度动画效果 ScaleAnimation 渐变尺寸伸缩动画效果 TranslateAnimation 画面转换位置移动动画效果 RotateAnimation 画面转移旋转动画效果 Android动画模式 Animation主要有两种

UI - Animation 动画类型

1 动画类型: 2 3 ** type 4 * 5 * 各种动画效果 其中除了'fade', `moveIn', `push' , `reveal' ,其他属于私有的API. 6 * ↑↑↑上面四个可以分别使用'kCATransitionFade', 'kCATransitionMoveIn', 'kCATransitionPush', 'kCATransitionReveal'来调用. 7 * @"cube" 立方体翻滚效果 8 * @"moveIn" 新视图移到