我想在我的UIViewController中有一个透明的背景,因为我像这样使用了clearColor
colorPickerVc.view.backgroundColor = UIColor.clearColor()
presentViewController(colorPickerVc, animated: true, completion: nil)
问题是当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)
为我工作,谢谢大家的帮助
最佳答案
colorPickerVc.modalPresentationStyle = UIModalPresentationStyle.OverCurrentContext
colorPickerVc.view.backgroundColor = UIColor.clearColor()