OGeek|极客世界-中国程序员成长平台

标题: objective-c - 延迟后触发方法而不滥用[UIView animateWithDuration]? [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 08:54
标题: objective-c - 延迟后触发方法而不滥用[UIView animateWithDuration]?

我有一个 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 的过渡并不是很干净。

是否有更好的方法来触发阻塞或发送消息,只需定义持续时间?

谢谢

祖帕



Best Answer-推荐答案


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

关于objective-c - 延迟后触发方法而不滥用[UIView animateWithDuration]?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7137591/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4