简体   繁体   English

将徽标添加到导航栏中的“后退”按钮的左侧

[英]Add logo to left side of Back button in navigation bar

I am trying to add a logo to the very left side of my navigation bar. 我正在尝试在导航栏的最左侧添加徽标。 I still want to display the Back button and the title of the page, but the logo must be fixed to the left side before the Back button. 我仍然想显示“后退”按钮和页面标题,但是徽标必须固定在“后退”按钮之前的左侧。

I tried adding the logo as a Bar Button Item, but this removes the Back button. 我尝试将徽标添加为“条形按钮项”,但这会删除“后退”按钮。

Is there any way to do this? 有什么办法吗? Thanks in advance! 提前致谢!

If you add a UIBarButtonItem as the leftBarButtonItem then you can also set the property 如果添加UIBarButtonItem作为leftBarButtonItem那么你也可以设置属性

self.navigationItem.leftItemsSupplementBackButton = true

This will allow you to have two buttons without disrupting the back button. 这将使您拥有两个按钮,而不会破坏后退按钮。 However it won't be on the far left, that space is reserved for the back button. 但是它不会在最左侧,该空间保留用于后退按钮。 If you want to go against Apple's design guidelines and the logo is more important the standard iOS navigation, you'll need to do something custom. 如果您想违反Apple的设计准则,并且徽标对于标准iOS导航更为重要,则需要进行一些自定义。

You could use the leftBarButtonItems property on UINavigationItem to set multiple items in your own order. 您可以使用UINavigationItem上的leftBarButtonItems属性以自己的顺序设置多个项目。 One of those could be a logo and another a custom back button that you set to call navigationController.popViewControllerAnimated(true) 其中一个可以是徽标,另一个可以是自定义后退按钮,您可以将其设置为调用navigationController.popViewControllerAnimated(true)

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

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