半透明Viewcontroller在另一个具有不同Orientation行为的Viewcontroller上

时间:2014-09-11 19:19:39

标签: objective-c ios7 orientation transparency ios8

对于针对iOS 7和iOS 8的应用,我使用了两个具有以下特征的ViewControllers:

  • ViewController 1(VC1)处于纵向模式
  • VC1创建了处于横向模式的ViewController 2(VC2)
  • VC2具有半透明背景,因此VC1的内容可见

我已经提到IOS 7: Transparent Viewcontroller Background over another Viewcontroller with different Orientation behaviour,但提供的解决方案不起作用。在iOS 8上,我可以获得VC2的横向或透明度,但不能同时获得

这就是我正在做的事情:

self.view.backgroundColor = [UIColor clearColor];

UILabel* label = [[UILabel alloc] initWithFrame:self.view.frame];
label.text = @" I'M VC1";

[self.view addSubview:label];

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
    LandscapeViewController* lvc = [[LandscapeViewController alloc] init];

    self.modalPresentationStyle = UIModalPresentationOverCurrentContext;

    //Uncomment this line for transparency but loses orientation
    //lvc.modalPresentationStyle = UIModalPresentationOverCurrentContext;

    [self presentViewController:lvc animated:YES completion:nil];

});

知道什么是错的,我怎么能让它运作?

0 个答案:

没有答案