Swift 为 UIImageView 背景添加透明色
Swift Add transparent color to UIImageView background
var controllerScreen = UIImageView()
controllerScreen.backgroundColor = UIColor.redColor()
这会向 UIImageView 添加不透明的红色。我想添加一种透明的红色。有没有透明的属性什么的?
您需要更改红色的 Alpha 值。你可以使用这样的东西:UIColor(red: 1.0, green: 0.0, blue: 0.0, alpha: 0.5)
作为@AdamPro13 答案的替代方案,您可以这样做:
controllerScreen.backgroundColor = UIColor.redColor().colorWithAlphaComponent(0.5)
var controllerScreen = UIImageView()
controllerScreen.backgroundColor = UIColor.redColor()
这会向 UIImageView 添加不透明的红色。我想添加一种透明的红色。有没有透明的属性什么的?
您需要更改红色的 Alpha 值。你可以使用这样的东西:UIColor(red: 1.0, green: 0.0, blue: 0.0, alpha: 0.5)
作为@AdamPro13 答案的替代方案,您可以这样做:
controllerScreen.backgroundColor = UIColor.redColor().colorWithAlphaComponent(0.5)