In Session 204 of the 2017 WWDC it was mentioned that you can now use Auto Layout in the UIViewController navigationItem.titleView
.
I tried various different options including the mentioned intrinsicContentSIze
, custom view with custom frame as well as a complete Auto Layout approach with fixed height.
No matter what I do, the navigation bar always shrinks down my views to 44 points.
Furthermore when using the AutoLayout only approach, I'm getting this constraint error:
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.
QUESTION:
Has anybody managed to make that work? How do you get custom navigation bar heights to adopt to your title views?