我正在使用当前的 View Controller 从左侧显示一个新的 View Controller 。 我使用的代码是..
UIViewController *controller;
UINavigationController *navi;
UIView *popmenu = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 300)];
popmenu.backgroundColor = [UIColor yellowColor];
controller.view = popmenu;
controller.view.superview.backgroundColor = [UIColor clearColor];
navi = [[UINavigationController alloc]initWithRootViewController:controller];
navi.view.superview.backgroundColor = [UIColor clearColor];
CATransition *transition = [CATransition animation];
transition.duration = 0.4;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromLeft;
[self.view.window.layer addAnimation:transition forKey:nil];
[self presentViewController:navi animated:NO completion:nil];
navi.view.superview.frame = CGRectMake(0, 0, 200, 540);
我得到的输出是.. 在这里我可以调整 View Controller 的 View 大小,但是如何调整 View Controller 的大小以便背景中存在的 View 我的意思是调用此模态视图的 View 将是可见的并且我可以执行操作..就像有一个按钮关闭此模态视图..谢谢..
最佳答案
您可以使呈现的 View Controller 透明,但如果您使用 presentViewController:animated:completion: 方法而不为呈现的 Controller 指定 UIViewControllerTransitioningDelegate,则呈现的 View Controller 将始终消失(即背景变为黑色)。
这是一个很好的教程,解释了如何在 iOS 7 上进行自定义转换 http://www.doubleencore.com/2013/09/ios-7-custom-transitions/
这是我的实验: https://github.com/Jafared/CustomTransitionTests
请注意,它仅适用于 iOS 7
关于ios - 如何使模态视图 Controller 透明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21380735/