SmoothNavDemo
SmoothNavDemo copied to clipboard
9.3.5 崩溃
iOS 9.3.5 应该是UINavigationBar的层级结构不一样造成了崩溃
// 设置导航栏背景透明度
- (void)setNeedsNavigationBackground:(CGFloat)alpha {
// 导航栏背景透明度设置
UIView *barBackgroundView = [[self.navigationBar subviews] objectAtIndex:0];// _UIBarBackground
UIImageView *backgroundImageView = [[barBackgroundView subviews] objectAtIndex:0];// UIImageView
if (self.navigationBar.isTranslucent) {
if (backgroundImageView != nil && backgroundImageView.image != nil) {
barBackgroundView.alpha = alpha;
} else {
// 崩溃位置
UIView *backgroundEffectView = [[barBackgroundView subviews] objectAtIndex:1];// UIVisualEffectView
if (backgroundEffectView != nil) {
backgroundEffectView.alpha = alpha;
}
}
} else {
barBackgroundView.alpha = alpha;
}
// 对导航栏下面那条线做处理
self.navigationBar.clipsToBounds = alpha == 0.0;
}
在viewWillAppear方法中设置透明度没遇到崩溃