ltebean / LTNavigationBar

UINavigationBar Category which allows you to change its appearance dynamically
MIT License
4.46k stars 677 forks source link

不知道原来作者去什么地方了,现在显示不出来的可以这样解决的 #37

Open langhua9527 opened 8 years ago

langhua9527 commented 8 years ago

把这个文件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;
}

因为返回回来之后self.overlay就跑最上面一层去了,并没有在最后面,所以就挡到了,显示不出来了 每次这样手动处理一下就好了

langhua9527 commented 8 years ago

`- (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.overlay.backgroundColor = backgroundColor;
dispatch_async(dispatch_get_main_queue(), ^{
    [self insertSubview:self.overlay atIndex:0];
});

}`

just try it , i fix it

yhjiang commented 7 years ago
- (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.overlay.backgroundColor = backgroundColor;
    dispatch_async(dispatch_get_main_queue(), ^{
        [self insertSubview:self.overlay atIndex:0];
    });
}

楼上的这个方法亲测可以解决,我iOS10.2系统 xcode8.2跑的