iOS9/10 fixups

This commit is contained in:
Michael Kirk 2018-07-31 14:28:41 -06:00
parent 78b4df95a5
commit def8b43daa
3 changed files with 21 additions and 20 deletions

View File

@ -418,7 +418,11 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations
[self addChildViewController:searchResultsController];
[self.view addSubview:searchResultsController.view];
[searchResultsController.view autoPinEdgesToSuperviewEdgesWithInsets:UIEdgeInsetsZero excludingEdge:ALEdgeTop];
[searchResultsController.view autoPinTopToSuperviewMarginWithInset:56];
if (@available(iOS 11, *)) {
[searchResultsController.view autoPinTopToSuperviewMarginWithInset:56];
} else {
[searchResultsController.view autoPinToTopLayoutGuideOfViewController:self withInset:40];
}
searchResultsController.view.hidden = YES;
[self updateBarButtonItems];

View File

@ -141,20 +141,9 @@ NS_ASSUME_NONNULL_BEGIN
// in iOS11 we have to ensure the navbar frame *in* layoutSubviews.
[navbar layoutSubviews];
} else {
// Pre iOS11 we size the navbar, and position it vertically once.
// in iOS9/10 we only need to size the navbar once
[navbar sizeToFit];
if (OWSWindowManager.sharedManager.hasCall) {
CGRect oldFrame = navbar.frame;
CGRect newFrame = oldFrame;
newFrame.size.height = navbar.callBannerHeight;
navbar.frame = newFrame;
} else {
CGRect oldFrame = navbar.frame;
CGRect newFrame
= CGRectMake(oldFrame.origin.x, navbar.statusBarHeight, oldFrame.size.width, oldFrame.size.height);
navbar.frame = newFrame;
}
[navbar layoutIfNeeded];
// Since the navbar's frame was updated, we need to be sure our child VC's
// container view is updated.

View File

@ -94,11 +94,18 @@ public class OWSNavigationBar: UINavigationBar {
if #available(iOS 11, *) {
return super.sizeThatFits(size)
} else {
// pre iOS11, sizeThatFits is repeatedly called to determine how much space to reserve for that navbar.
} else if #available(iOS 10, *) {
// iOS10
// sizeThatFits is repeatedly called to determine how much space to reserve for that navbar.
// That is, increasing this causes the child view controller to be pushed down.
// (as of iOS11, this is not used and instead we use additionalSafeAreaInsets)
return CGSize(width: fullWidth, height: navbarWithoutStatusHeight + statusBarHeight)
} else {
// iOS9
// sizeThatFits is repeatedly called to determine how much space to reserve for that navbar.
// That is, increasing this causes the child view controller to be pushed down.
// (as of iOS11, this is not used and instead we use additionalSafeAreaInsets)
return CGSize(width: fullWidth, height: navbarWithoutStatusHeight + callBannerHeight + 20)
}
}
@ -108,15 +115,16 @@ public class OWSNavigationBar: UINavigationBar {
return
}
guard #available(iOS 11, *) else {
super.layoutSubviews()
return
}
self.frame = CGRect(x: 0, y: callBannerHeight, width: fullWidth, height: navbarWithoutStatusHeight)
self.bounds = CGRect(x: 0, y: 0, width: fullWidth, height: navbarWithoutStatusHeight)
super.layoutSubviews()
guard #available(iOS 11, *) else {
return
}
// This is only necessary on iOS11, which has some private views within that lay outside of the navbar.
// They aren't actually visible behind the call status bar, but they looks strange during present/dismiss
// animations for modal VC's