After updating to IOS 16 I see my custom title view is getting placed in the wrong position on the y axis.
My app conditions are this:
-My custom title view isn't shown all the time (dynamically added/removed).
-When the custom title view is first set it is placed approximately at the center of the navigation bar on both the x and y axis as expected.
-After certain events happen my app sets the custom title view to nil to remove it.
-When I reset the custom title view, it gets placed either at the top or the bottom of the navigation bar on the y axis instead of the center.
This custom title view has a static frame, so I tried caching the size and returning it in -intrinsicContentSize but the system never calls intrinsicContentSize even though translatesAutoresizingMaskIntoConstraints is YES.
So I tried overriding -sizeThatFits: and that is actually called by the system but the issue persists because the size of the custom title view's frame is fine it's the origin that is wrong. So I logged out the frames of my custom title view its ancestor views like this:
NSLog(@"My frame: %@",NSStringFromCGRect(frame));
NSLog(@"superview %@ frame: %@",NSStringFromClass([superview class]),NSStringFromCGRect(superview.frame));
NSLog(@"superview.superview %@ frame: %@",NSStringFromClass([superview.superview class]),NSStringFromCGRect(superview.superview.frame));
When the custom title view is approx placed in the right location the first time its set the frames log out to this:
My frame: {{0, 0}, {161.5, 23}}
superview _UITAMICAdaptorView frame: {{0, 0}, {161.5, 23}}
superview.superview _UINavigationBarTitleControl frame: {{291.5, 3}, {161.5, 23}}
Then when it later gets reset and it is not properly placed on the y axis:
My frame: {{0, 0}, {161.5, 23}}
superview _UITAMICAdaptorView frame: {{0, 0}, {161.5, 23}}
superview.superview _UINavigationBarTitleControl frame: {{291.5, 24}, {161.5, 23}}
For some reason when the titleView is set the second time _UINavigationBarTitleControl yOrigin is 24.0. Initially it has a y origin of 3.0 when the custom title view appears to be in the correct location.