I have an application with some custom positioned bars, and as such I'd like to change the standard vertical alignment of the button text. I've tried setting
[buttonItem setTitlePositionAdjustment:UIOffsetMake(0, -22) forBarMetrics:UIBarMetricsDefault]
but nothing changes. Oddly, if I set a horizontal offset, the button moves just fine. It appears only vertical alignment changes are not being respected. Is this a bug on iOS 7? Am I misunderstanding something about the API? I see no documentation saying that the vertical alignment is ignored.
(example project showing the issue)
Unfortunately setTitlePositionAdjustment:forBarMetrics:
doesn't appear to take effect. The best workaround I found was to use a UIButton instead, which can be done right in Interface Builder.
UIButton
to the UIBarButtonItem
and set the font or image, size, etc.UIButton
's control alignment to rightIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With