UINavigationItem中的自动布局TitleView /如何自定义UINavigationBar高度?

时间:2017-11-15 06:06:21

标签: ios swift uinavigationbar ios11 uinavigationitem

在2017年WWDC会议204中,提到您现在可以在UIViewController navigationItem.titleView中使用自动布局。

我尝试了各种不同的选项,包括提到的intrinsicContentSIze,带自定义框架的自定义视图以及固定高度的完整自动布局方法。

无论我做什么,导航栏总是将我的视图缩小到44点。

此外,当使用AutoLayout only方法时,我收到此约束错误:

14:03:41.049847+0800 dfgd[60535:11623968] [LayoutConstraints] Unable to simultaneously satisfy constraints.
    Probably at least one of the constraints in the following list is one you don't want. 
    Try this: 
        (1) look at each constraint and try to figure out which you don't expect; 
        (2) find the code that added the unwanted constraint or constraints and fix it. 
(
    "<NSLayoutConstraint:0x600000092a70 UILayoutGuide:0x6000001b3160'TitleView(0x7f8beb6061c0)'.height == 44   (active)>",
    "<NSLayoutConstraint:0x600000092250 UIView:0x7f8beb602f50.height == 200   (active)>",
    "<NSLayoutConstraint:0x6000000920c0 V:[UIView:0x7f8beb602f50]-(10)-|   (active, names: '|':dfgd.CustomView:0x7f8beb602930 )>",
    "<NSLayoutConstraint:0x6000000925c0 UIView:0x7f8beb602f50.centerY == dfgd.CustomView:0x7f8beb602930.centerY   (active)>",
    "<NSLayoutConstraint:0x6040000938d0 dfgd.CustomView:0x7f8beb602930.top >= UILayoutGuide:0x6000001b3160'TitleView(0x7f8beb6061c0)'.top   (active)>",
    "<NSLayoutConstraint:0x604000094a50 dfgd.CustomView:0x7f8beb602930.bottom <= UILayoutGuide:0x6000001b3160'TitleView(0x7f8beb6061c0)'.bottom   (active)>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x600000092250 UIView:0x7f8beb602f50.height == 200   (active)>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.

问题

有人设法做到这一点吗?如何获得自定义导航栏高度以采用标题视图?

0 个答案:

没有答案