Nick Harris

Flip and Move a UIView – What Am I Doing Wrong?

leave a comment »

This is definitely a newbie question but I figure I’ll post it here then ask Twitter people for the answer cause its Monday and I’m feeling lazy.

I want to use UIView transitionWithView:duration:options:animations:completion: to flip a UIView and reposition it. The problem I’m having is that the first half of the animation has a clipped view. The second half works as expected.

Here’s the code:

– (void)viewDidLoad

{

    [superviewDidLoad];

    UITapGestureRecognizer *tapFlipView = [[UITapGestureRecognizeralloc] initWithTarget:selfaction:@selector(flip)];

    [self.flipView addGestureRecognizer:tapFlipView];

    

    self.flipView.backgroundColor = [UIColorredColor];

    self.isFlipViewUp = YES;

}

 

– (void)flip

{

    if( self.isFlipViewUp )

    {

        [UIViewtransitionWithView:self.flipView

                          duration:5.0

                           options:UIViewAnimationOptionTransitionFlipFromLeft

                        animations:^{

                            self.flipView.frame = CGRectOffset(self.flipView.frame, 0, 250);

                        } completion:^(BOOL finished) {

                            self.isFlipViewUp = NO;

                        }];

    }

    else

    {

        [UIViewtransitionWithView:self.flipView

                          duration:5.0

                           options:UIViewAnimationOptionTransitionFlipFromRight

                        animations:^{

                            self.flipView.frame = CGRectOffset(self.flipView.frame, 0, –250);

                        } completion:^(BOOL finished) {

                            self.isFlipViewUp = YES;

                        }];

    }

}

 

The result of this code looks like this:

What am I doing wrong?

Advertisements

Written by Nick Harris

July 8, 2014 at 12:55 am

Posted in Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: