1志于、導(dǎo)航欄的高度的適配
iOS 11以前夺饲,狀態(tài)欄statusBar的高度是20,底部tabbar的高度是49县钥。
iOS 11之后秀姐,狀態(tài)欄的statusBar的高度變成了44, 底部的tabbar變成了83
所以建議還是抽取成宏若贮。
2省有、安全區(qū)域的問(wèn)題
iOS 11之前, automaticallyadjustsscrollviewinsets經(jīng)常被設(shè)置成NO谴麦,由開(kāi)發(fā)者去控制處理留白和坐標(biāo)問(wèn)題蠢沿。
iOS 11后,把這個(gè)automaticallyadjustsscrollviewinsets廢棄匾效,新增了
contentInsetAdjustmentBehavior舷蟀,它是個(gè)枚舉類(lèi)型的值,我們只需要把其設(shè)置成never就行了.
#define adjustsScrollViewInsets_NO(scrollView,vc)\
do { \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Warc-performSelector-leaks\"") \
if ([UIScrollView instancesRespondToSelector:NSSelectorFromString(@"setContentInsetAdjustmentBehavior:")]) {\
[scrollView performSelector:NSSelectorFromString(@"setContentInsetAdjustmentBehavior:") withObject:@(2)];\
} else {\
vc.automaticallyAdjustsScrollViewInsets = NO;\
}\
_Pragma("clang diagnostic pop") \
} while (0)
3面哼、tableview的組頭和組尾高度變大問(wèn)題
我們需要在初始化的把這三屬性設(shè)置成0即可(
estimatedRowHeight雪侥、 estimatedSectionHeaderHeight estimatedSectionFooterHeight)
4、導(dǎo)航欄標(biāo)題titleview的問(wèn)題
iOS 11中會(huì)出現(xiàn)蜷縮成一起的現(xiàn)象 不過(guò)它現(xiàn)在支持autolayout精绎。所以我們需要把它擴(kuò)展出去, 只需要在你自定義的titleview中實(shí)現(xiàn)
- (CGSize)intrinsicContentSize {
return UILayoutFittingExpandedSize;
}
5锌妻、狀態(tài)欄獲取當(dāng)前網(wǎng)絡(luò)狀態(tài)(3G代乃、4G、Wifi、LTE...)
#pragma mark-獲取當(dāng)前網(wǎng)絡(luò)狀態(tài)
+(NSString *)getCurrentNetworkStatus{
NSString * networktype = nil;
// 因此可見(jiàn)iPhone X的狀態(tài)欄是多嵌套了一層搁吓,多取一次即可原茅,最終適配代碼為:
NSArray *subviews;
// 不能用 [[self deviceVersion] isEqualToString:@"iPhone X"] 來(lái)判斷,因?yàn)槟M器不會(huì)返回 iPhone X
if ([[[UIApplication sharedApplication] valueForKeyPath:@"_statusBar"] isKindOfClass:NSClassFromString(@"UIStatusBar_Modern")]) {
subviews = [[[[[UIApplication sharedApplication] valueForKeyPath:@"_statusBar"] valueForKeyPath:@"_statusBar"] valueForKeyPath:@"foregroundView"] subviews];
} else {
subviews = [[[[UIApplication sharedApplication] valueForKeyPath:@"_statusBar"] valueForKeyPath:@"foregroundView"] subviews];
}
// NSArray *subviews = [[[[UIApplication sharedApplication] valueForKey:@"statusBar"] valueForKey:@"foregroundView"]subviews];
NSNumber *dataNetworkItemView = nil;
for (id subview in subviews) {
if([subview isKindOfClass:[NSClassFromString(@"UIStatusBarDataNetworkItemView") class]]) {
dataNetworkItemView = subview;
break;
}
}
switch ([[dataNetworkItemView valueForKey:@"dataNetworkType"]integerValue]) {
case 0:
networktype = @"";
break;
case 1:
networktype=@"2G";
break;
case 2:
networktype=@"3G";
break;
case 3:
networktype=@"4G";
break;
case 4:
networktype=@"LTE";
break;
case 5:
networktype=@"Wifi";
break;
default:
networktype = @"";
break;
}
return networktype;
}
6堕仔、啟動(dòng)圖
7擂橘、設(shè)備內(nèi)編碼轉(zhuǎn)換設(shè)備名
@"iPhone10,1" : @"iPhone 8",
@"iPhone10,4" : @"iPhone 8",
@"iPhone10,2" : @"iPhone 8 Plus",
@"iPhone10,5" : @"iPhone 8 Plus",
@"iPhone10,3" : @"iPhone X",
@"iPhone10,6" : @"iPhone X",