iOS Dev (31) 动画进阶之一
iOS Dev (31) 动画进阶之一
- 作者:CSDN 大锐哥
- 地址:http://blog.csdn.net/prevention
-
说点废话
-
设置动画在 commitAnimations 之后的发生日期(感觉上一般不会跟 delay 一起使用)
setAnimationStartDate -
设置动画从 commitAnimation 之后延迟多久开始
setAnimationDelay -
设置动画持续的秒数
setAnimationDuration -
设置动画过程的相对速度
setAnimationCurve -
设置动画的重复次数
setAnimationRepeatCount -
设置动画到达目标值时是否自动反向播放
setAnimationRepeatAutoreverses -
设置是否激活动画
setAnimationsEnabled -
查看是否动画被激活
areAnimationEnabled
上点代码
自己看看动画代码段吧:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
UIImageView *imageView1 = [[UIImageView alloc] initWithFrame:CGRectMake(0, 20, 100, 100)];
imageView1.image = [UIImage imageNamed:@"gyy.jpg"];
imageView1.backgroundColor = [UIColor yellowColor];
imageView1.contentMode = UIViewContentModeScaleToFill; // 充满
[self.window addSubview:imageView1];
imageView1.tag = 1;
UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(10, 300, 200, 80)];
btn.backgroundColor = [UIColor blueColor];
[btn addTarget:self action:@selector(animate) forControlEvents:UIControlEventTouchUpInside];
[self.window addSubview:btn];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
- (void)animate
{
NSLog(@"haha");
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:10];
[UIView setAnimationDelay:0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
UIView *v = [self.window viewWithTag:1];
v.frame = CGRectMake(100, 100, 200, 80);
[UIView commitAnimations];
}
UIViewAnimationCurve
其中我们应该看到了 setAnimationCurve 方法,看看他都有哪些参数:
typedef NS_ENUM(NSInteger, UIViewAnimationCurve) {
UIViewAnimationCurveEaseInOut, // slow at beginning and end
UIViewAnimationCurveEaseIn, // slow at beginning
UIViewAnimationCurveEaseOut, // slow at end
UIViewAnimationCurveLinear
};
-
转载请注明来自:http://blog.csdn.net/prevention