码迷,mamicode.com
首页 > 其他好文 > 详细

animateWithDuration动画效果

时间:2015-07-23 21:52:08      阅读:337      评论:0      收藏:0      [点我收藏+]

标签:duration   效果   动画   

方法有

+ (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations

+ (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion

+ (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion

duration为动画持续的时间。

animations为动画效果的代码块。

下面是可以设置动画效果的属性:

frame

bounds

center

transform

alpha

backgroundColor

contentStretch

简易的动画代码

UIView *firstView = [[UIView alloc] initWithFrame:CGRectMake(50,50 , 100, 100)];
    firstView.backgroundColor = [UIColor redColor];

    UIView *secondView = [[UIView alloc] initWithFrame:CGRectMake(50, 50, 100, 100)];
    secondView.backgroundColor = [UIColor blueColor];
    secondView.alpha = 0.0;

    [self.view addSubview:firstView];
    [self.view addSubview:secondView];

    [UIView animateWithDuration:3.0 animations:^{

        firstView.alpha = 0.0;
        secondView.alpha = 1.0;
    }
                     completion:^(BOOL finished){

                     [UIView animateWithDuration:4.0

                                      animations:^{

                          secondView.center = CGPointMake(200, 400);
                          firstView.alpha = 1.0;}];
                     }];

completion为动画执行完毕以后执行的代码块

options为动画执行的选项。可以参考这里

delay为动画开始执行前等待的时间

版权声明:本文为博主原创文章,未经博主允许不得转载。

animateWithDuration动画效果

标签:duration   效果   动画   

原文地址:http://blog.csdn.net/wow09_1225/article/details/47028187

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!