How do you create a semi-transparent background for a UIView?

前端 未结 8 1048
耶瑟儿~
耶瑟儿~ 2021-02-13 10:19

I am creating a UIView containing some text that partially covers a UIImageView. I want the user to be able to read the text and still maintain a perspective on the image undern

8条回答
  •  滥情空心
    2021-02-13 10:59

    Swift 3+

    white half transparent:

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

    or black half transparent:

            view.backgroundColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.5)
    

提交回复
热议问题