Setting alpha on UIView sets the alpha on its subviews which should not happen

前端 未结 10 2371
借酒劲吻你
借酒劲吻你 2020-12-13 01:29

According to the documentation for UIVIew @property(nonatomic) CGFloat alpha

The value of this property is a floating-point number in the

10条回答
  •  南笙
    南笙 (楼主)
    2020-12-13 01:57

    Set Opacity of the background color instead of alpha will not affect its child views.

    1. select view.
    2. go to attribute inspector than background color
    3. click on "others"
    4. set opacity to 30%

    Or you can set by programmetically

    var customView:UIView = UIView()
    customView.layer.opacity = 0.3
    

    Thats it. Happy Coding!!!

提交回复
热议问题