ltebean / LTNavigationBar

UINavigationBar Category which allows you to change its appearance dynamically

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ios10适配

al1020119 opened this issue · comments

如果导航栏设置了透明的话,iOS10上面导航栏完全是是白色的标题也看不清。

我目前也遇到这个问题啊,求解!

#37 还是不能解决问题。

我的是自定义一个naviBar,默认是不显示背影,上拉后淡出。
我的解决方法:

if (IS_iOS10) {
    naviBar.translucent = YES;
    [naviBar lt_setBackgroundColor:[UIColor clearColor]];
}

文件UINavigationBar+Awesome.h 里面的方法lt_setBackgroundColor 要是下面的:

- (void)lt_setBackgroundColor:(UIColor *)backgroundColor
{
    if (!self.overlay) {
        [self setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
        self.overlay = [[UIView alloc] initWithFrame:CGRectMake(0, -20, [UIScreen mainScreen].bounds.size.width, CGRectGetHeight(self.bounds) + 20)];
        self.overlay.userInteractionEnabled = NO;
        self.overlay.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
        [self insertSubview:self.overlay atIndex:0];
    }
    self.overlay.backgroundColor = backgroundColor;
}

@al1020119

issues里有人提过这个问题,据说新版v2.1.7解决了,不过我这边尝试透明时还是显示白色。
后来仿照了美团app,直接隐藏了_UINavigationBarBackground(iOS9)或_UIBarBackground(iOS10)这个view,背景自然就透明了,然后自定义了个view,放在导航栏下面,通过设置view的背景色来达到每个控制器导航栏颜色不同的需求。