iOS add / remove shadow from a view

后端 未结 6 2192
遇见更好的自我
遇见更好的自我 2021-02-12 22:14

I do not understand how to remove a shadow that was added to a view. I add to my view in initWithFrame a shadow in this way:

self.layer.borderWidth          


        
6条回答
  •  别跟我提以往
    2021-02-12 23:11

    I guess you could use the shadowOpacity property of your CALayer.

    So this should work:

    self.layer.shadowOpacity = 0;
    

    See the CALayer's shadowOpacity documentation page

    And to show your shadow use:

    self.layer.shadowOpacity = 1.0;
    

提交回复
热议问题