简体   繁体   English

当导航栏中的“后退”按钮没有标题时,停止将其左移

[英]stop left bar button from being shifted right when back button has no title in navigation bar

I am removing the title to the back bar button in the navigation bar with: 我使用以下命令删除导航栏中后退按钮的标题:

self.navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: .Plain, target: nil, action: nil)

This works great, however, I have a problem when I add a left bar button for another action to the navigation bar with: 这很好用,但是,当我向导航栏添加另一个动作的左栏按钮时,我遇到了一个问题:

self.addLeftBarButtonWithImage(UIImage(named: "menu_lines")!)

The left bar button shows up shifted right from the back bar button as if the back bar button still has title text. 左栏按钮显示为从后栏按钮向右偏移,好像后栏按钮仍具有标题文本。 I would like the new left bar button to be right beside the back icon '<', but there is horizontal space in-between that I can't figure out how to remove. 我希望新的左栏按钮位于后方图标“ <”旁边,但是它们之间有水平空间,无法弄清楚该如何去除。

在此处输入图片说明

Try adding them with self.navigationItem.leftBarButtonItems = [] and add UIBarButton objects to the array! 尝试使用self.navigationItem.leftBarButtonItems = []添加它们,并将UIBarButton对象添加到数组中! You must set your own actions in this case but it should take care of what you're trying to do 在这种情况下,您必须设置自己的操作,但是它应该照顾您要执行的操作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM