在iOS 7中的另一个ViewController上显示清晰的彩色ViewController [英] Display clear colored ViewController over another ViewController in iOS 7
问题描述
在iOS 7之前,根据这个流行的Stackoverflow 提问,显示一个具有清晰背景的ViewController是在主ViewController中执行以下操作:
Prior to iOS 7, according to this popular Stackoverflow question, the way to show a ViewController with a clear background was to do the following in the main ViewController:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"SecondViewController"];
vc.view.backgroundColor = [UIColor clearColor];
self.modalPresentationStyle = UIModalPresentationCurrentContext;
[self presentViewController:vc animated:NO completion:nil];
然而,正如我最近在iOS 7中发现的那样(以及其他人对主要答案的评论) ,上述解决方案不再有效,而只是显示黑色模型控制器。我知道透明度主要用于iOS 7,因此透明视图控制器很有可能。我还没有发现这个问题的解决方法,并且想知道是否有人知道如何解决这个问题。谢谢!
However, as I have recently discovered with iOS 7 (and as commented by others to the main answer), the above solution no longer works, and instead just shows a black model controller. I know that transparency is largely used in iOS 7, so that transparent view controller is very likely possible. I haven't discovered a workaround to this issue yet, and was wondering if anyone knows how to resolve this problem. Thanks!
推荐答案
我只是按照原始解决方案在Interface Builder中应用了一些默认和自定义设置,在我看来它是加工。
I just followed the original solution and applied some default and custom settings in Interface Builder, and seems to me it is working.
- You can check it here: https://github.com/codedad/SO_IOS_viewcl_on_viewcl
重要部分(与问题代码非常相似) :
Important section (quite similar to the question's code):
- (IBAction)click:(id)sender {
NSLog(@"click");
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"TopOverVc"];
vc.view.backgroundColor = [UIColor clearColor];
self.modalPresentationStyle = UIModalPresentationCurrentContext;
[self presentViewController:vc animated:NO completion:nil];
}
-
同时请找到IB snaphot :
Also pls find the IB snaphot:
模拟器结果(按下按钮后):
And the simulator result (after pressing button):
希望我没有误解你的问题中的sthing;)快乐的编码!
Hope I did not misunderstand sthing in your question ;) Happy coding!
这篇关于在iOS 7中的另一个ViewController上显示清晰的彩色ViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!