I would like to center a button in my navigationBar, which is currently defined as a rightBarButtonItem :
UIBarButtonItem *audioBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemPlay target:self action:@selector(toggleAudioPlayback:)];
self.navigationItem.rightBarButtonItem = audioBtn;
[audioBtn release];
You can use the .titleView
property of your navigation item - but you'll need to create your own assets for this (you won't be able to use a UIBarButtonItem). From Apple's docs:
...(titleViews) can contain buttons. Use the buttonWithType: method in UIButton class to add buttons to your custom view in the style of the navigation bar. Custom title views are centered on the navigation bar and may be resized to fit.
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