listenzz / HBDNavigationBar

A custom UINavigationBar for smooth switching between various states, including bar style, bar tint color, background image, background alpha, bar hidden, title text attributes, tint color, shadow hidden...
MIT License
1.65k stars 216 forks source link

为啥只有首页的导航栏透明度设置无效? #170

Open sharehoney opened 2 years ago

sharehoney commented 2 years ago

我在自定义的TabbarCtrl里设置了3个Ctrl,分别是:首页、题库、我的;

但是‘首页’的导航栏透明度设置无效,始终显示白色的背景,而其他2个Ctrl却好用;

代码基本相同,这是为啥哩?

listenzz commented 2 years ago

可否提供个小 demo 给我看看

sharehoney commented 2 years ago

好像是xib文件中设置的问题 —— 有个背景图片,如果top设置成相对superView为0 导航栏就透明,如果设置成相对safeArea为0 导航栏就是一白条。

使用您框架的部分代码如下:

// self.navigationItem.title = @"首页";

self.extendedLayoutIncludesOpaqueBars = YES;
self.navigationController.navigationBar.hidden = NO;

//  ---------------------------------

self.hbd_barHidden = NO;
self.hbd_barShadowHidden = YES;

self.hbd_barAlpha = 0.0;
self.hbd_barStyle = UIBarStyleDefault;

// self.hbd_tintColor = UIColor.redColor;

// self.hbd_barTintColor = [UIColor clearColor]; // self.hbd_barImage = [UIImage new];

// self.hbd_titleTextAttributes = @{ NSForegroundColorAttributeName: [UIColor redColor]}; // self.hbd_titleTextAttributes = @{ NSForegroundColorAttributeName: [UIColor clearColor]};

//  ---------------------------------

// [self setHbd_extendedLayoutDidSet:YES]; [self hbd_setNeedsUpdateNavigationBar];

}

sharehoney commented 2 years ago

哦,如果我设置了hbd_barAlpha = 0.0,那导航栏上面的控件是不是也不应该显示了啊,比如: self.navigationItem.titleView = _theSearchBar

listenzz commented 2 years ago

哦,如果我设置了hbd_barAlpha = 0.0,那导航栏上面的控件是不是也不应该显示了啊,比如: self.navigationItem.titleView = _theSearchBar

只是背景透明,元素不透明

sharehoney commented 2 years ago

嗯嗯,谢谢。

listenzz commented 2 years ago

我在自定义的TabbarCtrl里设置了3个Ctrl,分别是:首页、题库、我的;

但是‘首页’的导航栏透明度设置无效,始终显示白色的背景,而其他2个Ctrl却好用;

代码基本相同,这是为啥哩?

我这边不方便重现问题,想要快速解决问题,最好提供一个完整的 demo 给我