Use Storyboard to mask UIView and give rounded corners?

前端 未结 4 2033
余生分开走
余生分开走 2020-12-23 00:23

Lots of questions like this explain how to programmatically create a mask and provide rounded corners to a UIView.

Is there a way to do it all within Storyboard? Jus

4条回答
  •  孤城傲影
    2020-12-23 00:53

    Yes, I use that a lot but question like this was already answered many times.

    But anyway in Interface Builder. You need to add User Defined Runtime Attributes like this:

    layer.masksToBounds Boolean YES
    layer.cornerRadius Number {View's Width/2}
    

    and enable

    Clips subviews
    

    Results:

提交回复
热议问题