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

(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动画必须通过修改属性的真实值,才有动画效果。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值