首页 > 代码库 > 模态视图和父视图之间转换的方法
模态视图和父视图之间转换的方法
1.模态视图的静态工厂方法调用:
+ (void)dismiss
{
UIWindow *window;
window = [UIApplicationsharedApplication].keyWindow;
if([window.rootViewControllerisKindOfClass:[ASDepthModalViewControllerclass]])
{
ASDepthModalViewController *controller;
controller = (ASDepthModalViewController *)window.rootViewController;
[controllerdismiss];
}
}
2.调用实力变量的模态视图转化函数
- (void)dismiss
{
[UIViewanimateWithDuration:kModalViewAnimationDuration
animations:^{
self.coverView.alpha =0;
self.rootViewController.view.transform = CGAffineTransformIdentity;
self.popupView.transform =self.initialPopupTransform;
}
completion:^(BOOL finished) {
[selfrestoreRootViewController];
}];
}
3.重新修改根视图控制器:
- (void)restoreRootViewController
{
UIWindow *window;
window = [UIApplicationsharedApplication].keyWindow;
[self.rootViewController.viewremoveFromSuperview];
self.rootViewController.view.transform = window.rootViewController.view.transform;
window.rootViewController =self.rootViewController;
}
模态视图和父视图之间转换的方法