Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/98.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios performSelector的替代选项:withObject:afterDelay:用于对视图进行同等动画_Ios_Objective C_Animation - Fatal编程技术网

Ios performSelector的替代选项:withObject:afterDelay:用于对视图进行同等动画

Ios performSelector的替代选项:withObject:afterDelay:用于对视图进行同等动画,ios,objective-c,animation,Ios,Objective C,Animation,我有一个方法-(void)animationStart,它包含很多[自执行选择器:@selector(myAnimation)with object:nil afterDelay:21*0.01]具有不同的方法和延迟 如何重构代码,使其不使用performSelector?我使用它来进行动画的后续更改。您没有指定动画本身的具体执行方式,但是使用UIView动画块,您还可以指定延迟。(animateWithDuration:delay:options:animations:completion:)

我有一个方法
-(void)animationStart
,它包含很多
[自执行选择器:@selector(myAnimation)with object:nil afterDelay:21*0.01]具有不同的方法和延迟


如何重构代码,使其不使用
performSelector
?我使用它来进行动画的后续更改。

您没有指定动画本身的具体执行方式,但是使用UIView动画块,您还可以指定延迟。(
animateWithDuration:delay:options:animations:completion:

或者,您可以使用
NSTimer
执行延迟

但要获得详细答案,您应该提供有关如何执行动画的更多详细信息

更新

使用动画块非常简单…在完成块(请参见下面的代码)中,可以启动后续动画(对于一系列动画)。对于并行动画处理,您只需启动多个动画块…有不同的消息。如果不需要处理动画结束,可以使用不带完成块的动画结束

以下是一个例子:

[UIView animateWithDuration:2.0 delay:0.1 options:UIViewAnimationOptionCurveEaseInOut animations:^{

    // perform animation code here

} completion:^(BOOL finished) {

    // This code is performed after the animation is completed. E.g. you can start a new animation here
    // (for serial animation processing):

}];

如果我将使用并行或串联动画,如何使用
animateWithDuration
。我试过了,但没有成功。我更新了我的答案。在这里,您可以看到如何触发一系列动画。要执行并行动画,只需启动多个动画块。