0

I am trying to flip a UIView around one edge of the view, as if the view were a page of a calendar with a rigid page moving over like so : Calendar.

I am trying to do it like so :

[UIView transitionWithView:self.upperCard
                      duration:0.5
                       options:UIViewAnimationOptionTransitionFlipFromBottom
                    animations:^{
                            topView.frame = [self bottomHalfRectFromBounds];
                            bottomView.frame = [self topHalfRectFromBounds];
                            topView.flippedOver = YES;
                            bottomView.flippedOver = NO;
                       }
                    completion:NULL];

[self setNeedsDisplay];

The only problem with this method is that because the animation of the view's frame is Linear and so is the flipping animation the animation's are out of time with each other (This is due to the fact that flipping at a constant velocity the area which is visible of the view is proportional to Cos(t), learn some maths if you didn't know that ;P).

So basically I'm either looking for a way to make the frame animation have an easing function... or a completely alternative method... I don't want this to look like a page curl as it is going to be used for a scoreboard app, so please don't just tell me to use the UIViewAnimationOptionCurlDown option :P

Thanks for your time!

simonthumper
  • 1,834
  • 2
  • 22
  • 44

1 Answers1

0

In general, animating your view’s frame is not a good way to approach this: it causes the view to have to redraw itself at every step of the animation, and, as you’ve noticed, doesn’t look like a flip so much as a linear scale.

Check out this answer—specifically the second part of it, discussing how to do it in CA—for a better approach.

Community
  • 1
  • 1
Noah Witherspoon
  • 57,021
  • 16
  • 130
  • 131