Presenting TransLucent Modal

by sisccr

POPUp view with a translucent background is simple way to add a cool effect on our app.

My storyBoard settings is show in this figure.

Its a simple view with little bit of opacity. Note that Alpha value is 0.8 and its backgroundColor is Black.

popUp view is simply just an another view.

screen-shot-2016-11-20-at-11-23-51-am

First grab that popUp viewController.

 let popUp = UIStoryboard.storyBoardWith(sbType: .ClubDetail).viewController() as RatingPopUp2

Then set the Modal presentation style. It defines how this modal should be presented.

 popUp.modalPresentationStyle = UIModalPresentationStyle.OverCurrentContext

Since I have  all viewControllers setup in a tabBarController, I want to present this view from the rootViewController, So that the tab bar settings remains behind this view.

So, I grab the RootViewcontroller and present this view from it.

 
let rootViewController = UIApplication.sharedApplication().keyWindow?.rootViewController
 rootViewController?.presentViewController(popUp, animated: true, completion: nil)

Result: 

A Sleek effect 🙂

bestresult

 

Advertisements