Fixup for iPhoneX

// FREEBIE
pull/1/head
Michael Kirk 7 years ago committed by Matthew Chen
parent 778e11c2c3
commit 3383c5e80c

@ -53,9 +53,10 @@ NS_ASSUME_NONNULL_BEGIN
} else {
self.additionalSafeAreaInsets = UIEdgeInsetsZero;
}
// in iOS11 we have to ensure the position *in* layoutSubviews.
[navbar layoutSubviews];
} else {
// Pre iOS11 we have to position the frame manually
// Pre iOS11 we size the navbar, and position it vertically once.
[navbar sizeToFit];
if (OWSWindowManager.sharedManager.hasCall) {

@ -16,12 +16,16 @@ class OWSNavigationBar: UINavigationBar {
weak var navBarLayoutDelegate: NavBarLayoutDelegate?
let navbarWithoutStatusHeight: CGFloat = 44
let callBannerHeight: CGFloat = 40
let callBannerHeight: CGFloat = OWSWindowManagerCallScreenHeight()
var statusBarHeight: CGFloat {
return 20
}
var fullWidth: CGFloat {
return UIScreen.main.bounds.size.width
}
override init(frame: CGRect) {
super.init(frame: frame)
@ -51,7 +55,7 @@ class OWSNavigationBar: UINavigationBar {
// pre iOS11, 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)
let result = CGSize(width: CurrentAppContext().mainWindow!.bounds.width, height: navbarWithoutStatusHeight + statusBarHeight)
let result = CGSize(width: fullWidth, height: navbarWithoutStatusHeight + statusBarHeight)
Logger.debug("\(self.logTag) in \(#function): \(result)")
@ -60,15 +64,15 @@ class OWSNavigationBar: UINavigationBar {
}
override func layoutSubviews() {
Logger.debug("\(self.logTag) in \(#function)")
Logger.debug("\(self.logTag) in \(#function) with frame: \(frame)")
guard OWSWindowManager.shared().hasCall() else {
super.layoutSubviews()
return
}
self.frame = CGRect(x: 0, y: callBannerHeight, width: UIScreen.main.bounds.width, height: navbarWithoutStatusHeight)
self.bounds = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: navbarWithoutStatusHeight)
self.frame = CGRect(x: 0, y: callBannerHeight, width: fullWidth, height: navbarWithoutStatusHeight)
self.bounds = CGRect(x: 0, y: 0, width: fullWidth, height: navbarWithoutStatusHeight)
super.layoutSubviews()

@ -13,6 +13,7 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark -
extern NSString *const OWSWindowManagerCallDidChangeNotification;
const CGFloat OWSWindowManagerCallScreenHeight(void);
extern const UIWindowLevel UIWindowLevel_Background;

@ -13,11 +13,10 @@ NS_ASSUME_NONNULL_BEGIN
NSString *const OWSWindowManagerCallDidChangeNotification = @"OWSWindowManagerCallDidChangeNotification";
const CGFloat OWSWindowManagerCallScreenHeight(void);
const CGFloat OWSWindowManagerCallScreenHeight(void)
{
if ([UIDevice currentDevice].isIPhoneX) {
return 60;
return 64;
} else {
return 40;
}

Loading…
Cancel
Save