From 6ed6fd34477bfc9519c3fc768d6dd69b72da1a80 Mon Sep 17 00:00:00 2001 From: miniLV Date: Wed, 26 Sep 2018 18:29:01 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=20-=20iPhone=20X=20=E5=AF=BC?= =?UTF-8?q?=E8=88=AA=E6=9D=A1=E9=AB=98=E5=BA=A6=E9=80=82=E9=85=8D=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LTNavigationBar/UINavigationBar+Awesome.m | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/LTNavigationBar/UINavigationBar+Awesome.m b/LTNavigationBar/UINavigationBar+Awesome.m index 10adb5b..e1d3a62 100644 --- a/LTNavigationBar/UINavigationBar+Awesome.m +++ b/LTNavigationBar/UINavigationBar+Awesome.m @@ -28,7 +28,14 @@ - (void)lt_setBackgroundColor:(UIColor *)backgroundColor { if (!self.overlay) { [self setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault]; - self.overlay = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.bounds), CGRectGetHeight(self.bounds) + 20)]; + + //解决 iPhone X 适配问题 + CGFloat toolHeight = 20; + if ([[UIScreen mainScreen] bounds].size.height >= 812.0f) { + //说明是iPhone X + toolHeight = 44; + } + self.overlay = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.bounds), CGRectGetHeight(self.bounds) + toolHeight)]; self.overlay.userInteractionEnabled = NO; self.overlay.autoresizingMask = UIViewAutoresizingFlexibleWidth; // Should not set `UIViewAutoresizingFlexibleHeight` [[self.subviews firstObject] insertSubview:self.overlay atIndex:0];