[英]clearColor make background color black
我希望在我的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()
尝试将视图的图层的不透明度设置为零,而不是使用清晰的颜色
clearColor()实际上正在工作,但是如果你在元素后面没有任何东西你就会生成clearColor(),那么屏幕将是黑色的,因为当没有任何东西可以显示时它看起来如何
你真的在你明确的对象背后有什么东西吗?
什么颜色或图像或背景应该是什么?
因为它是一个颜色选择器,我假设你想要在后台使用最后一个viewController,但你正在做的是创建一个全新的屏幕,所以这样做的方法可能是没有选择器作为viewController但只是作为UIView放置在上一个viewController上的叠加层或者如评论中提到的那样,获取截图并将其置于后面
在调试中查看colorPickerVc.view.superView
和colorPickerVc.view.superView.superView
是什么。 在呈现视图控制器时,不仅是添加到层次结构的视图。
我在几个视图中遇到了同样的问题,而我所要做的就是在故事板中将不透明特性设置为NO(未选中)。 (使用Xcode 9 beta)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.