Created
November 6, 2012 22:18
-
-
Save benjaminbojko/4028025 to your computer and use it in GitHub Desktop.
Flip and Reload a single UIView
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// based on http://stackoverflow.com/questions/347721/how-do-i-apply-a-perspective-transform-to-a-uiview | |
[UIView animateWithDuration:0.3f delay:0.0f options:UIViewAnimationOptionBeginFromCurrentState|UIViewAnimationOptionCurveEaseIn animations:^{ | |
CATransform3D rotationAndPerspectiveTransform = CATransform3DIdentity; | |
rotationAndPerspectiveTransform.m34 = 1.0 / -500; | |
rotationAndPerspectiveTransform = CATransform3DRotate(rotationAndPerspectiveTransform, M_PI_2, 0.0f, 1.0f, 0.0f); | |
[self.view.layer setTransform:rotationAndPerspectiveTransform]; | |
} completion:^(BOOL finished) { | |
// REFRESH YOUR VIEW HERE | |
CATransform3D rotationAndPerspectiveTransform = CATransform3DIdentity; | |
rotationAndPerspectiveTransform.m34 = 1.0 / -500; | |
rotationAndPerspectiveTransform = CATransform3DRotate(rotationAndPerspectiveTransform, -M_PI_2, 0.0f, 1.0f, 0.0f); | |
[self.view.layer setTransform:rotationAndPerspectiveTransform]; | |
[UIView animateWithDuration:0.3f delay:0.0f options:UIViewAnimationOptionCurveEaseOut animations:^{ | |
[self.view.layer setTransform:CATransform3DMakeRotation( 0.0f, 0.0f, 1.0f, 0.0f)]; | |
} completion:^(BOOL finished) { | |
}]; | |
}]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment