NavigationBar loaded from Xcode8 xib issue
wujianbotju opened this issue · comments
In Xcode8, size of any UIView loaded from xib has changed to be (1000, 1000). So if I load a single UINavigationBar(not from UINavigationController) from xib, its height will be 1020, the view of UIViewController will be covered by the overlay, which is added by LTNavigationBar.
Solution: Auto layout should be used, don't use "self.overlay.autoresizingMask = UIViewAutoresizingFlexibleWidth;" Just like the following:
// self.overlay.autoresizingMask = UIViewAutoresizingFlexibleWidth; // Comment out this line
self.overlay.translatesAutoresizingMaskIntoConstraints = NO;
[[self.subviews firstObject] insertSubview:self.overlay atIndex:0];
NSArray *hConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"H:|-(0)-[overlay]-(0)-|" options:0 metrics:nil views:@{@"overlay":self.overlay}];
NSArray *vConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"V:|-(-20)-[overlay]-(0)-|" options:0 metrics:nil views:@{@"overlay":self.overlay}];
[self.overlay.superview addConstraints:hConstraints];
[self.overlay.superview addConstraints:vConstraints];