SmoothNavDemo icon indicating copy to clipboard operation
SmoothNavDemo copied to clipboard

9.3.5 崩溃

Open shafujiu opened this issue 7 years ago • 1 comments

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;
}

shafujiu avatar Sep 21 '17 09:09 shafujiu

在viewWillAppear方法中设置透明度没遇到崩溃

YogaChen avatar Oct 20 '17 10:10 YogaChen