延迟后触发方法而不滥用[UIView animateWithDuration]?

时间:2011-08-21 10:02:05

标签: objective-c ios timer uiviewanimation

我有一个UIViewController,它应该控制2个UIImageViews淡入。

我设法使用UIView animateWithDuration方法为它们设置动画,如下所示:

[UIView animateWithDuration:1.5
    animations:^{
      [mFrontpageTitle setAlpha:0];
      [mFrontpageTitle setAlpha:1];
    }
    completion:^(BOOL finished){
      [self AnimatePause];
    }];

-(void)AnimatePause {
[UIView animateWithDuration:5.0
    animations:^{
      [mFrontpageTitle setAlpha:0.99];
      [mFrontpageTitle setAlpha:1];
    }
    completion:^(BOOL finished){
      [self AnimateAuthor];
    }];

触发下一个动画。现在,创建从.99到1.0的过渡并不是很干净。

是否有更好的方法通过定义持续时间来触发阻止或发送消息?

感谢

Zuppa

1 个答案:

答案 0 :(得分:3)

NSTimeInterval delay = 1.5; //in seconds
[self performSelector:@selector(myMethod) withObject:nil afterDelay:delay];