- (void)flipCurrentView {
NSUInteger reflectionHeight;
UIImage *reflectedImage;
// disable user interaction during the flip
containerView.userInteractionEnabled = NO;
flipIndicatorButton.userInteractionEnabled = NO;
// setup the animation group
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.75];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(myTransitionDidStop:finished:context:)];
// swap the views and transition
if (frontViewIsVisible==YES) {
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:containerView cache:YES];
[atomicElementView removeFromSuperview];
[containerView addSubview:atomicElementFlippedView];
// update the reflection image for the new view
reflectionHeight=atomicElementFlippedView.bounds.size.height*reflectionFraction;
reflectedImage = [atomicElementFlippedView reflectedImageRepresentationWithHeight:reflectionHeight];
reflectionView.image=reflectedImage;
} else {
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:containerView cache:YES];
[atomicElementFlippedView removeFromSuperview];
[containerView addSubview:atomicElementView];
// update the reflection image for the new view
reflectionHeight=atomicElementView.bounds.size.height*reflectionFraction;
reflectedImage = [atomicElementView reflectedImageRepresentationWithHeight:reflectionHeight];
reflectionView.image=reflectedImage;
}
[UIView commitAnimations];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.75];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(myTransitionDidStop:finished:context:)];
if (frontViewIsVisible==YES)
{
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:flipIndicatorButton cache:YES];
[flipIndicatorButton setBackgroundImage:element.flipperImageForAtomicElementNavigationItem forState:UIControlStateNormal];
}
else
{
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:flipIndicatorButton cache:YES];
[flipIndicatorButton setBackgroundImage:[UIImage imageNamed:@"flipper_list_blue.png"] forState:UIControlStateNormal];
}
[UIView commitAnimations];
frontViewIsVisible=!frontViewIsVisible;
}