How can I have an opaque UIView as a subview of a semi-transparent UIView?

前端 未结 5 1517
时光说笑
时光说笑 2020-12-24 06:47

I have a UIView with an alpha of 0.5 which I add as a subview to my primary view in order to gray-out everything else. I want to add an additional UIView to this gray UIVie

5条回答
  •  北荒
    北荒 (楼主)
    2020-12-24 07:27

    This will only work if you have any image on the background.

    Instead of reducing the alpha of UIView, add an UIImageView on that view and then reduce the alpha of the UIImageView.

    now add your subviews on the UIView.

    your subviews will not take the alpha property anymore.. :)

提交回复
热议问题