iphone - 在 iOS 7 中的另一个 ViewController 上显示清晰的彩色 ViewController

标签 iphone ios ios7 transparency

<分区>

在 iOS 7 之前,根据这个流行的 Stackoverflow question,显示具有清晰背景的 ViewController 的方法是在主 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 中发现的那样(以及其他人对主要答案的评论),上述解决方案不再有效,而是只显示一个黑色模型 Controller 。我知道透明度主要用于 iOS 7,因此透明 View Controller 很有可能成为可能。我还没有找到解决这个问题的方法,想知道是否有人知道如何解决这个问题。谢谢!

最佳答案

我只是按照最初的解决方案并在 Interface Builder 中应用了一些默认和自定义设置,在我看来它正在运行。

重要部分(与问题的代码非常相似):

- (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 快照: enter image description here

  • 模拟器结果(按下按钮后):

enter image description here

希望我没有误解你的问题;)编码愉快!

关于iphone - 在 iOS 7 中的另一个 ViewController 上显示清晰的彩色 ViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19486530/

相关文章:

ios - 通知中心今天小部件闪烁然后 "unable to load"Swift

iphone - 从另一个 modalviewcontroller 中解除 modalviewcontroller

ios - 文本字段应该返回自动滚动屏幕

html - 我希望简单帮助页面中的 href 链接能够在 Safari 中打开

iOS 7 TableView 类似于 iPad 上的设置应用程序

ios - 如何在聊天框的一个 UIlabel 中制作文本和 URL 链接

iphone - 如何计算距离用户最近的位置?

ios - 使用 Eureka 框架更改表格样式

iOS 10.1 模拟器显示 "Application May Slow Down Your iPhone"

html - iOS - 在 flexbox 中带有输入元素的 float 光标