0

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

代码:

- (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
}

这是基本思想......

谢谢你。

4

2 回答 2

2

您可以使用基于块的 UiView 动画来做到这一点:

[UIView animateWithDuration:0.4 animations:^{
    //Your first anim here
} completion:^(BOOL finished){
    //Your second anim here
}];
于 2012-07-13T12:58:03.473 回答
1

你也可以在你的方法中使用

[self performSelector:@selector(animateCardSize) withObject:nil afterDelay:(2.0f)];
//2.0 and animateCardSize as examples
于 2012-07-13T15:18:26.507 回答