Fabio Poloni Fabio Poloni - 3 months ago 25
Objective-C Question

Get the width of a UIBarButtonItem

I'm trying to get the width of a

UIBarButtonItem
.

This doesn't work:

barbuttonitem.customView.frame.size.width


And this won't work, either:

barbuttonitem.width

Answer

What about this:

UIBarButtonItem *item = /*...*/;
UIView *view = [item valueForKey:@"view"];
CGFloat width = view? [view frame].size.width : (CGFloat)0.0;