I have a UIBarButtonItem
in a Navigation Bar with the text title "Save". When I transition to a fullscreen UIPopoverController
and then dismiss it, the text in my UIBarButtonItem gets truncated to "S..e". For all other segues and views I have no problem when returning.
I've tried manually changing the width and setting "possibleTitles" to include long words but I can't stop the truncation.
I'm using a custom font if that makes a difference.
Try to init your UIBarButtonItem with a custom view.
[[UIBarButtonItem alloc] initWithCustomView:yourView];
Just make sure your custom view has the right frame (e.g. for an UILabel ,wide enough to not truncate its content). Things should work fine.
Perhaps helpful, but a UIBarButtonItem
with a custom view (ex: UILabel
) that is inserted into a UIToolbar
can take on the intrinsic size of its contents as long as translatesAutoresizingMaskIntoConstraints
is set to false
. I believe this may work for UINavigationBar
too:
private let barButtonLabel: UIBarButtonItem = {
let label = UILabel(frame: .zero)
label.translatesAutoresizingMaskIntoConstraints = false
return UIBarButtonItem(customView: label)
}()
If 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