Reputation: 1972
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)
Upvotes: 15
Views: 3943
Reputation: 39460
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 rightUpvotes: 4