How to Set opacity for View in iOS?


View’s Alpha value is a floating-point number in the range 0.0 to 1.0, where 0.0 represents totally transparent and 1.0 represents totally opaque. Changing the value of this property updates the alpha value of the current view only.

You can simply adjust alpha value based on the opacity you want.

Write the following line in you viewDidLoad method

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

Run the application, the view’s opacity you can see is 50%


raja
Published on 16-Jul-2019 14:58:33
Advertisements