Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm trying to present a viewcontroller with a transparent background on both iOS 7 and iOS 8. Just by changing the viewcontroller's modalPresentationStyle property to FormSheet I can get it working on iOS 7.1.

What I want is a universal way to that on ios7+

I have tried using other options to modalPresentationStyle, like: OverCurrentContext, CurrentContext and PageSheet.

I also tried to use the modalPresentationStyle.Custom but didnt have any success.

I have NavigationController if that helps in anything.

The code for the presenting view controller:

InfoViewController *info = [[InfoViewController alloc] initWithNibName:@"InfoViewController" bundle:nil];
[self presentViewController:info animated:YES completion:nil];

And the code for the viewDidLoad(which I think has a relevant part on this) of the presented ViewController:

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view.
    self.modalPresentationStyle = UIModalPresentationStyle.PageSheet
}

I′m using swift and Xcode 6. Here′s a screenshot of what I have now and of what I want, respectively:

enter image description hereenter image description here

Here's an example code: https://github.com/pbassut/TransBackgroundViewController

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.2k views
Welcome To Ask or Share your Answers For Others

1 Answer

For those still with this problem before presenting the UIViewController set the modalPresentationStyle of the presented UIViewController to .Custom and it will work on iOS 8(Xcode 6.1). That is, you should set it in the presenting UIViewController


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...