+ (void)transformViewController1:(UIViewController* )vc1 withViewController2:(UIViewController* )vc2{
__weak typeof(UIViewController* ) weakSelf = vc1;
[UIView animateWithDuration:0.5 delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
UIWindow *window = [UIApplication sharedApplication].keyWindow;
window.backgroundColor = [UIColor whiteColor];
window.layer.transform = CATransform3DMakeRotation(M_PI/2.0, 0, 1, 0);
} completion:^(BOOL finished) {
[weakSelf presentViewController:vc2 animated:NO completion:nil];
[UIView animateWithDuration:0 animations:^{
vc2.view.layer.transform = CATransform3DMakeRotation(3*M_PI/2, 0, 1, 0);// 先将页面翻转270度。此时是你看不见这个控制器的,设置了alpha
} completion:^(BOOL finished) {
vc2.view.alpha = 1;
[UIView animateWithDuration:0.5 animations:^{
// 先将window 翻转270.
UIWindow *window = [UIApplication sharedApplication].keyWindow;
window.backgroundColor = [UIColor whiteColor];
window.layer.transform = CATransform3DRotate(window.layer.transform,M_PI*3/2.0, 0, 1, 0);
vc2.view.layer.transform = CATransform3DRotate(vc2.view.layer.transform, M_PI/2, 0, 1, 0);
} completion:^(BOOL finished) {
}];
}];
}];
}
+ (void)transformViewController2:(UIViewController* )vc2 withViewController1:(UIViewController* )vc1{
__weak typeof(UIViewController* ) weakSelf = vc2;
[UIView animateWithDuration:0.5 delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
weakSelf.view.layer.transform = CATransform3DMakeRotation(M_PI/2.0, 0, 1, 0); // 当前view,这句代码可以不要。这是我的需求
UIWindow *window = [UIApplication sharedApplication].keyWindow;
window.backgroundColor = [UIColor whiteColor];
window.layer.transform = CATransform3DMakeRotation(M_PI/2.0, 0, 1, 0);
} completion:^(BOOL finished) {
[weakSelf dismissViewControllerAnimated:NO completion:nil];
[UIView animateWithDuration:0 animations:^{
vc1.view.layer.transform = CATransform3DMakeRotation(3*M_PI/2, 0, 1, 0);// 先将页面翻转270度。此时是你看不见这个控制器的,设置了alpha
} completion:^(BOOL finished) {
vc1.view.alpha = 1;
[UIView animateWithDuration:0.5 animations:^{
// 先将window 翻转270.
UIWindow *window = [UIApplication sharedApplication].keyWindow;
window.backgroundColor = [UIColor whiteColor];
window.layer.transform = CATransform3DRotate(window.layer.transform,M_PI*3/2.0, 0, 1, 0);
vc1.view.layer.transform = CATransform3DRotate(vc1.view.layer.transform, M_PI/2, 0, 1, 0);
} completion:^(BOOL finished) {
}];
}];
}];
}
网友评论