将按钮置于导航栏中居中
我想在导航栏中居中放置一个按钮,该按钮当前定义为 rightBarButtonItem :
UIBarButtonItem *audioBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemPlay target:self action:@selector(toggleAudioPlayback:)];
self.navigationItem.rightBarButtonItem = audioBtn;
[audioBtn release];
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];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用导航项的
.titleView
属性 - 但您需要为此创建自己的资产(您将无法使用 UIBarButtonItem)。来自苹果的文档: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: