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 { } else {
self.additionalSafeAreaInsets = UIEdgeInsetsZero; self.additionalSafeAreaInsets = UIEdgeInsetsZero;
} }
// in iOS11 we have to ensure the position *in* layoutSubviews.
[navbar layoutSubviews]; [navbar layoutSubviews];
} else { } else {
// Pre iOS11 we have to position the frame manually // Pre iOS11 we size the navbar, and position it vertically once.
[navbar sizeToFit]; [navbar sizeToFit];
if (OWSWindowManager.sharedManager.hasCall) { if (OWSWindowManager.sharedManager.hasCall) {

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

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

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

Loading…
Cancel
Save