xplat
xplat

Reputation: 8626

Add delays between UIView Animations

I have some operations and animations inside the touchesBegan method of UIView which I subclassed and append as class in my View. I need some delay between the animations.

Code:

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

This is the basic idea.....

Thank you.

Upvotes: 0

Views: 616

Answers (2)

Chris Tetreault
Chris Tetreault

Reputation: 1973

You could also use in your method

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

Upvotes: 1

iSofTom
iSofTom

Reputation: 1718

You can do so with Block-based UiView animations:

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

Upvotes: 2

Related Questions