How to add a drop shadow to a UIButton?

后端 未结 5 1007
面向向阳花
面向向阳花 2020-12-02 07:14

I would like to add a drop shadow to a UIButton. I tried to use self.layer.shadow* properties. Those properties work in UIView, but they behave differently in UIButton. I wo

5条回答
  •  無奈伤痛
    2020-12-02 07:18

    You can subclass UIButton and overwrite the drawRect: method and add manually a drop shadow. That's much more work and you should now a few things about quartz 2d, but the result is exactly what you want. Otherwise you could just add an image, but I prefere to subclass UIButton, because it is very flexible regarding the size of the button, it's more general.

提交回复
热议问题