Swift UIView background color opacity

The Solution to Swift UIView background color opacity is


You can set background color of view to the UIColor with alpha, and not affect view.alpha:

view.backgroundColor = UIColor(white: 1, alpha: 0.5)

or

view.backgroundColor = UIColor.red.withAlphaComponent(0.5)

~ Answered on 2014-12-12 08:11:08


Most Viewed Questions: