Swift为UIImageView背景添加透明色

Sam*_*ain 1 iphone xcode uiimageview ios swift

var controllerScreen   = UIImageView()
controllerScreen.backgroundColor = UIColor.redColor()
Run Code Online (Sandbox Code Playgroud)

这为UIImageView添加了红色不透明的颜色.我想添加透明的红色.有透明属性还是什么?

ABa*_*ith 5

作为@ AdamPro13的替代方案,你可以做到:

controllerScreen.backgroundColor = UIColor.redColor().colorWithAlphaComponent(0.5)
Run Code Online (Sandbox Code Playgroud)