#define iOS10 ([[UIDevice currentDevice].systemVersion intValue]>=10?YES:NO)
- (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[self.navigationController.navigationBar.subviews enumerateObjectsUsingBlock:^(UIView *view, NSUInteger idx, BOOL *stop) {
if (iOS10) {
//iOS10,改变了导航栏的私有接口为_UIBarBackground
if ([view isKindOfClass:NSClassFromString(@"_UIBarBackground")]) {
[view.subviews lastObject].hidden = YES;
}
}else{
//iOS10之前使用的是_UINavigationBarBackground
if ([view isKindOfClass:NSClassFromString(@"_UINavigationBarBackground")]) {
[view.subviews lastObject].hidden = YES;
}
}
}];
}
本文介绍了一种方法来适配iOS10中的导航栏显示变化,通过判断设备是否运行在iOS10及以上版本,并根据不同的iOS版本调整导航栏背景的隐藏状态。
9356

被折叠的 条评论
为什么被折叠?



