SmoothNavDemo
SmoothNavDemo copied to clipboard
在iOS8和iOS9中会崩溃……
将UINavigationController+Cloudox.m 方法“- (void)setNeedsNavigationBackground:(CGFloat)alpha” 中的barBackgroundView、backgroundImageView、backgroundEffectView修改成下方……
// 导航栏背景透明度设置 UIView *barBackgroundView;// _UIBarBackground UIImageView *backgroundImageView;// UIImageView UIView *backgroundEffectView;// UIVisualEffectView
if (@available(iOS 10.0, *)) {//
barBackgroundView = [self.navigationBar.subviews objectAtIndex:0];
backgroundImageView = [barBackgroundView.subviews objectAtIndex:0];
backgroundEffectView = [barBackgroundView.subviews objectAtIndex:1];
}else{
for (UIView *view in self.navigationBar.subviews) {
if ([view isKindOfClass:NSClassFromString(@"_UINavigationBarBackground")]) {
barBackgroundView = view;
}
}
for (UIView *otherView in barBackgroundView.subviews) {
if ([otherView isKindOfClass:NSClassFromString(@"UIImageView")]) {
backgroundImageView = (UIImageView *)otherView;
}else if ([otherView isKindOfClass:NSClassFromString(@"_UIBackdropView")]) {
backgroundEffectView = otherView;
}
}
}
竟然又发现了一个坑……
iOS 这个导航栏就是个大坑啊。。