简体   繁体   English

我如何将navigationItem.titleView放在左右栏按钮项的后面

[英]how do I have the navigationItem.titleView to be behind left and right bar button item

Is it possible to have the titleView to be behind the left and right bar button item on a navigation bar? 是否可以将titleView放在导航栏上左右栏按钮项的后面? I've set my titleView to have a width of 320 and it covers the left and right bar button item. 我将titleView设置为320的宽度,它涵盖了左右栏按钮的项目。 I wonder if there is a way to move it to the back? 我想知道是否有办法将其移到后面?

In my experiments, it appears that the titleView is always drawn after (above) the left and right bar button items. 在我的实验中,似乎总是在左右栏按钮项之后(上方)绘制titleView You could try spelunking the view hierarchy and using sendSubviewToBack: , provided that the title view is ever made part of the navigation bar's hierarchy. 如果标题视图曾经成为导航栏层次结构的一部分,则可以尝试拼凑视图层次结构并使用sendSubviewToBack:

If you can render the effect you're trying to achieve into an image, you could set that as the backgroundImage of the navigation bar, but this may not be practical. 如果可以将要实现的效果渲染为图像,则可以将其设置为导航栏的backgroundImage ,但这可能不切实际。

Remember that you'll likely need to account for interface rotation in any case, since the navigation bar height (on iPhone) goes from 44px in portrait to 32px in landscape). 请记住,在任何情况下,您都可能需要考虑界面旋转,因为导航栏的高度(在iPhone上为纵向的44px变为横向的32px)。

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

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