您的位置:首页 > 产品设计 > UI/UE

oc新手学习细节之(UIView)动画总结

2016-04-10 11:00 387 查看

(UIView)动画总结

1.头尾式动画

// 开启动画

[UIView beginAnimations:nil context:nil];

// 设置动画时间

[UIView setAnimationDuration:1.0];

/需要执行动画的代码/

// .提交动画

[UIView commitAnimations];

代理方法

+(void)setAnimationDelegate:(id)delegate

设置动画代理对象,当动画开始或者结束时会发消息给代理对象

+(void)setAnimationWillStartSelector:(SEL)selector

当动画即将开始时,执行delegate对象的selector,并且把beginAnimations:context:中传入的参数传进selector

+(void)setAnimationDidStopSelector:(SEL)selector

当动画结束时,执行delegate对象的selector,并且把beginAnimations:context:中传入的参数传进selector

2.block式

[UIView animateWithDuration:(时间) animations:^{

需要执行动画的代码


}];

弹簧效果的动画

// animateWithDuration: 动画时间

// delay: 延迟多久执行

// usingSpringWithDamping: 弹性系数,越小,弹簧效果越明显

// initialSpringVelocity: 初始速度

// options: 速度模式

// animations: 执行动画代码

// completion: 动画执行后

[UIView animateWithDuration:0.6 delay:0 usingSpringWithDamping:0.2 initialSpringVelocity:10 options:UIViewAnimationOptionCurveEaseInOut animations:^{

} completion:^(BOOL finished) {

}];

3.序列帧动画

: 把有序的图片一张一张播放出来

//告示tom要播放哪些图片

self.tom.animationImages = images;

//    2.1设置播放动画的次数,不可以在播放之后

self.tom.animationRepeatCount = 0;(0就是重复)

//    2.2设置播放时间

self.tom.animationDuration =images.count * 0.1;

//    3.播放

[self.tom startAnimating];


4.系统自带

比较多,就不比一一列举了

[self.imageScroll setContentOffset:<#(CGPoint)#> animated:<#(BOOL)#>];

5.autolayout的动画

在修改了约束之后,只要执行下面代码,就能做动画效果

[UIView animateWithDuration:1.0 animations:^{

[添加了约束的view layoutIfNeeded];


}];

UIView动画和layer动画区别 ?

核心动画一切都是假象,并不会真实的改变图层的属性值,如果以后做动画的时候,不需要与用户交互,通常用核心动画(转场)。

UIView动画必须通过修改属性的真实值,才有动画效果。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  uiview