UIView动画学习笔记

来源:互联网 发布:逆战神枪手源码 编辑:程序博客网 时间:2024/05/16 11:55

UIView的动画有两种实现方式:

1. 使用UIView的方法

 [UIView beginAnimations:@"anib" context:nil];
    [UIView setAnimationDuration:0.5];
    view1.frame = fram1;
    view2.frame = fram2;
    view3.frame = fram3;
    [UIView commitAnimations]; 

2. 使用UIView.layer的方法
 CATransition *animation = [CATransition animation];
    animation.duration = 0.5f;
    animation.timingFunction = UIViewAnimationCurveEaseInOut;
animation.fillMode = kCAFillModeForwards;
animation.removedOnCompletion = NO;//不能移除动画,否则ui就会还原
    animation.subtype = @"fromLeft";
    animation.type = @"oglFlip";
    animation.endProgress = 0.2;
    [view2.layer addAnimation:animation forKey:@"ani"]; 

最后顺带定时器的 使用:
 [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(initPic1) userInfo:nil repeats:NO]; 

0 0
原创粉丝点击