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动画必须通过修改属性的真实值,才有动画效果。
相关文章推荐
- iOS应用开发中UIView添加边框颜色及设置圆角边框的方法
- CALayer与UIView的关系
- UIView的bounds和frame区别
- uiview
- uiview生命周期
- UIView翻译 (参考)
- iOS 转变UIView到UIImage
- UIView动画
- initWithFrame 和 initWithCoder
- [CS193P] 第六堂課摘要及心得筆記
- UI第一天
- 棋盘
- ios实现button变换颜色并可以放大、缩小、旋转
- uiview contentViewmode
- iphone开发小记 基础知识2
- iphone开发小记 基础知识3
- [笔记]I 群聊天记录2012/03/中
- iPhone开发进阶(2) --- iPhone应用程序/项目的构成
- 视图弹出后放大又缩小的动画实现、类似于alertView效果
- iPhone SDK开发:自定义UIAlertView