【发布时间】:2016-12-07 09:15:36
【问题描述】:
这是我的导航栏
现在我知道如何使用此代码在leftBarButtonItem 上添加customView
navigationItem.leftBarButtonItem!.customView = someCustomView
如我的截图所示
但问题是,有没有办法可以检测到我的leftBarButtonItem 旁边是否有任何navigationItems,以便我可以将宽度设置为动态?而不是像屏幕截图那样重叠?
这是我的测试用例的更多屏幕截图
注意:是的,我知道如何使用代码 someCustomView.frame = CGRect(.....) 设置框架,而且 UINavigationBar/Item 似乎继承自 NSObject 而不是 UIView
编辑:显然在进行了大量编码、重新编码和研究之后,UINavigationBar/UINavigationItem 的唯一部分会根据左右自动调整自身大小/strong> barButtons 是 titleView 在某种程度上很烂。
是通过使用 UINavigationItem 的 titleView 属性,它不能回答我的问题。
【问题讨论】:
标签: ios swift xcode uinavigationitem