Sameer Hussain
Sameer Hussain

Reputation: 2551

Swift Add transparent color to UIImageView background

var controllerScreen   = UIImageView()
controllerScreen.backgroundColor = UIColor.redColor()

This adds red opaque color to the UIImageView. I want to add a transparent red color. Is there any transparent property or something ?

Upvotes: 1

Views: 11365

Answers (2)

ABakerSmith
ABakerSmith

Reputation: 22939

As an alternative to @AdamPro13's answer you could do:

controllerScreen.backgroundColor = UIColor.redColor().colorWithAlphaComponent(0.5)

Upvotes: 5

AdamPro13
AdamPro13

Reputation: 7400

You need to change the alpha value of the red color. You can use something like this: UIColor(red: 1.0, green: 0.0, blue: 0.0, alpha: 0.5)

Upvotes: 4

Related Questions