Search code examples
iosswiftios9

View Controller Transparent Background


How can I create a view controller with a transparent background that overlays another view controller where the bottom view controller is still visible in iOS 9? The way that works in iOS 8 no longer works.


Solution

  • First you can set overlaid view controller's background colour as clear colour.

    You can use presentViewController method to overlay new view controller.

    This from apple docs

    When presenting a view controller using the UIModalPresentationFullScreen style, UIKit normally removes the views of the underlying view controller after the transition animations finish. You can prevent the removal of those views by specifying the UIModalPresentationOverFullScreen style instead.

    So you can set overlaid view controller's modalPresentationStyle to UIModalPresentationOverFullScreen

    I also hope this may be help

    When using one of the full-screen presentation styles, the view controller that initiates the presentation must itself cover the entire screen. If the presenting view controller does not cover the screen, UIKit walks up the view controller hierarchy until it finds one that does. If it can’t find an intermediate view controller that fills the screen, UIKit uses the root view controller of the window.