0

I have subclassed UINavigationBar and overridden drawRect method so I can add a gradient to it. Now, I want to use the same gradient to the back button, but I don't know what is the easiest way (subclass UIButton, subclass UIBarButton item)

Thank you.

Cosmin
  • 2,840
  • 5
  • 32
  • 50

3 Answers3

1

A lot of people on StackOverflow caution against subclassing UIButton. create uibutton subclass

The easiest way to do what you want is to use [UIButton buttonWithType:UIButtonTypeCustom].

Make a transparent .png image of your button and set it as your button.image.

Community
  • 1
  • 1
David Chu
  • 329
  • 2
  • 3
0

You can have a look here: http://www.cimgf.com/2010/01/28/fun-with-uibuttons-and-core-animation-layers/

TheEye
  • 9,280
  • 2
  • 42
  • 58
  • The thing is that I want the default shape of my back button, I just want to add a gradient to it. If I subclass UIButton I don't think I can build the button to have the exact shape. – Cosmin Mar 08 '12 at 10:49