How do I programmatically provide a glossy look to UIButtons?

后端 未结 3 1264
隐瞒了意图╮
隐瞒了意图╮ 2021-01-06 12:45

I would like to add 3D or glossy look to some iPhone UIButtons, but do so without the use of PNGs or stretchable images. I have a lot of buttons of varying shapes and sizes

3条回答
  •  迷失自我
    2021-01-06 12:53

    One way to do this programatically is to modify properties of a UIButton's layer. For example, you can add an instance of CAGradientLayer as a sublayer, set the layer's corner radius, modify it's border, etc. Matt Long has written a great article about this:

    http://www.cimgf.com/2010/01/28/fun-with-uibuttons-and-core-animation-layers/

提交回复
热议问题