How to determine height of UIBarButtonItem?

I am shrinking the height of the enclosing UIToolbar and don't want to clip the button. Anyone know how to get at the height value?

Thanks, Patrick

Answered by PatrickM in 752572022

For anyone interested, you can set the height of the toolbar with a constraint. I figured out how to determine the UIBarButton height: Construct it from a UIButton (custom view). The frame of that button gives you what you need. I then set the toolbar constraint to have the height a few points more than the button frame's height.

There is no means to do this because we support neither getting the sizing of a UIBarButtonItem nor arbitrary vertical sizing for UIToolbar. If you need something like this, we'd probably recommend you use your own UI element rather than UIToolbar.

Accepted Answer

For anyone interested, you can set the height of the toolbar with a constraint. I figured out how to determine the UIBarButton height: Construct it from a UIButton (custom view). The frame of that button gives you what you need. I then set the toolbar constraint to have the height a few points more than the button frame's height.

How to determine height of UIBarButtonItem?
 
 
Q