I solved it by creating a custom view controller where i placed a UIView
at the centre with the dimensions similar to the alert box and set its constraints to centre horizontally
, centre vertically
, fixed width
and fixed height
. Inside i place a label
with the text and the long space in between the place where the image has to be. then i place a image view
with the image correctly in this gap.
The view's corner radius is set to 13px
and background color to match the alert box style.
Then as @Sushree's answer suggested, set the presentation style. But setting it programmatically didn't work for me. But setting it in the StoryBoard
works for all IOS versions (8.0 to 9.3) as i checked.
Select UIViewController
->Attributes inspector
->Presentation
->Over Current Context
I am using a UINavigationController
as the RootViewController
so i used the following code
if let wd = appDelegate.window {
var vc = wd.rootViewController
if(vc is UINavigationController){
vc = (vc as! UINavigationController).visibleViewController
vc!.presentViewController(PopupViewController, animated: false, completion: nil)
}
}
Reference answer