views:

3321

answers:

1

Hi there,

I am creating a UIBarButtonItem with a custom view in order to achieve a transition to a UIActivityIndicatorView as described here - however I really want my button to retain a normal UIBarButtonItemStyle such as UIBarButtonitemStyleBordered

Is there a way to achieve this?

Thanks!

+4  A: 

If I understand the question, you want to have something like the Locate button in Maps.app, where it shows the target icon and changes into an activity indicator whiile it's locating the device?

Unfortunately UIBarButtonItems created with -initWithImage:style:target:action: or -initWithTitle:style:target:action: don't support arbitrary views inside the button.

You'll probably have to draw the button border yourself. You could use an image for that, and achieve the effect by stacking a UIActivityIndicatorView on top of a UIImageView containing an image of a button border.

Fraser Speirs