[英]Swift Add transparent color to UIImageView background
var controllerScreen = UIImageView()
controllerScreen.backgroundColor = UIColor.redColor()
This adds red opaque color to the UIImageView. 这将红色不透明颜色添加到UIImageView。 I want to add a transparent red color.
我想添加透明的红色。 Is there any transparent property or something ?
有透明的东西吗?
作为@ AdamPro13答案的替代方法,您可以执行以下操作:
controllerScreen.backgroundColor = UIColor.redColor().colorWithAlphaComponent(0.5)
You need to change the alpha value of the red color. 您需要更改红色的Alpha值。 You can use something like this:
UIColor(red: 1.0, green: 0.0, blue: 0.0, alpha: 0.5)
您可以使用如下形式:
UIColor(red: 1.0, green: 0.0, blue: 0.0, alpha: 0.5)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.