clearColor使背景颜色变黑

tam*_*987 4 xcode objective-c ios swift

我希望在我的UIViewController中有一个透明的背景,因为我使用了clearColor

colorPickerVc.view.backgroundColor = UIColor.clearColor()
presentViewController(colorPickerVc, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)

问题是当colorPickerVc完成加载时,背景颜色变黑了我想要一个解决方案,如果可能的话,在ios 7上工作,谢谢你的帮助


@ 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)
Run Code Online (Sandbox Code Playgroud)

为我工作,谢谢你们的帮助

goo*_*4pc 5

colorPickerVc.modalPresentationStyle = UIModalPresentationStyle.OverCurrentContext
colorPickerVc.view.backgroundColor = UIColor.clearColor()
Run Code Online (Sandbox Code Playgroud)