UIBarButtonItem with custom view but also with UIBarButtonItemStyle

I am creating a UIBarButtonItem with a custom view to navigate to a UIActivityIndicatorView , as described here .

However, I really want my button to maintain a normal UIBarButtonItemStyle , such as a UIBarButtonitemStyleBordered .

Is there any way to achieve this?

Thanks in advance!

+4
source share
1 answer

If I understand the question, do you want something like the Locate button in Maps.app, where it shows the target icon and changes it to an activity indicator when it finds the device?

Unfortunately, UIBarButtonItems created using -initWithImage:style:target:action: or -initWithTitle:style:target:action: does not support arbitrary views inside the button.

You may have to draw the border of the button yourself. You can use the image for this and achieve the effect by stacking the UIActivityIndicatorView on top of the UIImageView containing the button border image.

+6
source

All Articles