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

动画反转与重复

时间:2014-12-16 20:58:53      阅读:160      评论:0      收藏:0      [点我收藏+]

标签:style   blog   io   color   使用   sp   on   div   log   

 动画的反转

执行与否与放置的位置有关。
若放在动画对象动画动作之前,则执行,否则不执行。
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:2];
    [UIView setAnimationRepeatAutoreverses:YES];
    [UIView setAnimationRepeatCount:2];
    imageView.frame = CGRectMake(170, 300, 60, 50);   //执行返回一次,然后再回到动画结束的位置,即 (170, 300, 60, 50)
    [UIView commitAnimations];

若将这两句的位置调换,即

imageView.frame = CGRectMake(170, 300, 60, 50);
[UIView setAnimationRepeatCount:2];
[UIView setAnimationRepeatAutoreverses:YES];  //不执行反转

动画的重复要与反转在一起搭配使用才能呈现效果

[UIView setAnimationRepeatCount:2];  //设置动画重复次数要与反转放在一起,否则也不起作用
[UIView setAnimationRepeatAutoreverses:YES];
imageView.frame = CGRectMake(170, 300, 60, 50);

如果分开放,只会反转一次(默认为一次)。

[UIView setAnimationRepeatAutoreverses:YES];
imageView.frame = CGRectMake(170, 300, 60, 50);
[UIView setAnimationRepeatCount:2];  //只反转一次

 

动画反转与重复

标签:style   blog   io   color   使用   sp   on   div   log   

原文地址:http://www.cnblogs.com/hyhl23/p/4167953.html

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