在UIView动画之间添加延迟



我在UIView的touchesBegan方法中有一些操作和动画,我将其子类化并附加为View中的类。动画之间我需要一些延迟。

代码:

- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    // Add delay to imitate the hold for touch 1 second and if true continue
    // else cancel everything
    [self animateViewSize]; // Here animates the view frame
    // Add delay until sizing animation ends.....
    [self animateViewFlip]; // Here animates the view flip y axis
    [[NSNotificationCenter defaultCenter] postNotificationName:@"A Notification" object:self];
    // Notify the superview Controller that touch happened and do some operations with  animations too...
    // Some variables appending values for the UIView location when it touched
}
- (void) animateCardSize
{
    // Animate using UIView animation
}
- (void) animateFlipView
{
     // Animate flip using CABasicAnimation
}

这是基本的想法。。。。。

谢谢。

您可以使用基于块的UiView动画:

[UIView animateWithDuration:0.4 animations:^{
    //Your first anim here
} completion:^(BOOL finished){
    //Your second anim here
}];

您也可以在方法中使用

[self performSelector:@selector(animateCardSize) withObject:nil afterDelay:(2.0f)];
//2.0 and animateCardSize as examples

最新更新