This worked for me:
[modalView.superview setBackgroundcolor:[UIColor clearColor]]
It will still hide the appearance of the background transparently, but will not cover it with solid gray.
...............................................
UPDATE FOR iOS 8
My previous solution no longer works for iOS 8. There are many steps to get something like this to work in iOS 8. So I created a nice reusable solution: ModalController https://github.com/koreyhinton/ModalController .
It is very easy to use and automatically fires itself.
let modal = ModalController() modal.content = myCustomView presentViewController(modal, animated: true, completion: nil)
If you are interested in implementation details, here is how I did it:
Make your modal view controller full screen, and the main background of the view will switch between transparent and semi-dark. After that, you will have a view of the content, which will be modal, which will be centered by the solid background color. I also use the presentation style: .OverCurrentContext , which I assign in the init method.
var content = UIView() override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = UIColor.clearColor() content.frame = CGRect(x:0, y:0, width:300, height:300) content.backgroundColor = UIColor.blackColor() view.addSubview(content) } override func viewDidAppear(animated: Bool) { super.viewDidAppear(animated) view.backgroundColor = UIColor.blackColor().colorWithAlphaComponent(0.7) } override func viewWillDisappear(animated: Bool) { super.viewWillDisappear(animated) view.backgroundColor = UIColor.clearColor() } override func viewDidLayoutSubviews() { super.viewDidLayoutSubviews() content!.center = view.center }
source share