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:
Here's an example code: https://github.com/pbassut/TransBackgroundViewController
Basic Swift Code for iOS AppsView's Alpha value is a floating-point number in the range 0.0 to 1.0, where 0.0 represents totally transparent and 1.0 represents totally opaque. Changing the value of this property updates the alpha value of the current view only.
Just add a Storyboard Segue with Kind set to Present Modally to your modal view controller and on this view controller set the following values: Background = Clear Color. Drawing = Uncheck the Opaque checkbox.
The UIViewController class defines the methods and properties for managing your views, handling events, transitioning from one view controller to another, and coordinating with other parts of your app.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With