Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

clearColor make background color black

I want to have a tranparent background in my UIViewController for that I used clearColor like this

colorPickerVc.view.backgroundColor = UIColor.clearColor()
presentViewController(colorPickerVc, animated: true, completion: nil)

the problem is when colorPickerVc finished loading, the background color become black I want a solution if possible that work on ios 7 to thank's for your help


Solution of @good4pc :

colorPickerVc.view.backgroundColor = UIColor.clearColor()
if #available(iOS 8.0, *) 
{
    colorPickerVc.modalPresentationStyle = UIModal PresentationStyle.OverCurrentContext
} 
else 
{
     colorPickerVc.modalPresentationStyle = UIModalPresentationStyle.CurrentContext
}

presentViewController(colorPickerVc, animated: true, completion: nil)

work for me, thank you guys for your help

like image 429
tamtoum1987 Avatar asked Jul 21 '16 12:07

tamtoum1987


1 Answers

colorPickerVc.modalPresentationStyle = UIModalPresentationStyle.OverCurrentContext
colorPickerVc.view.backgroundColor = UIColor.clearColor()
like image 172
good4pc Avatar answered Nov 12 '22 10:11

good4pc