1

我在 SO 上看到了一些与此相关的问题,但他们似乎都没有完全回答这个问题:delay部分UIView animateWithDuration:delay:options:animate:completion:不会延迟。这是调用它的实际代码:

-(void) viewDidAppear:(BOOL)animated
{
    NSLog(@"about to start animateWithDuration...");

    [UIView animateWithDuration:3.0 delay:2.0 options:UIViewAnimationOptionTransitionNone
                     animations:^{NSLog(@"in the animations block..."); self.textView.hidden = YES;}
                     completion:^(BOOL finished){if (finished) {NSLog(@"In the completion block..."); self.textView.hidden = NO; [self.player play];}}];
}

这是NSLog时间戳:

2013-06-18 15:27:16.607 AppTest1[52083:c07] 即将开始 animateWithDuration...

2013-06-18 15:27:16.608 AppTest1[52083:c07] 在动画块中......

2013-06-18 15:27:16.609 AppTest1[52083:c07] 在完成块中......

可以看到,指令的执行间隔为毫秒,而不是延迟 2 或 3 秒。有人知道这是什么原因吗?

4

1 回答 1

7

hidden属性是不可动画的:

该类的以下属性UIView是可动画的:

@property frame

@property bounds

@property center

@property transform

@property alpha

@property backgroundColor

@property contentStretch

尝试在动画块中使用这些属性之一,然后应该会发生延迟。例如,您可以为alphafrom 1.0to设置动画0.0,然后将其隐藏在完成块中。

于 2013-06-18T18:42:24.253 回答