Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
sharehoney opened this issue May 7, 2022 · 6 comments
Open

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

sharehoney opened this issue May 7, 2022 · 6 comments

Comments

@sharehoney
Copy link

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

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

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

@listenzz
Copy link
Owner

listenzz commented May 7, 2022

可否提供个小 demo 给我看看

@sharehoney
Copy link
Author

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

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

  • (void)prepareNavigationBar {

// 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
Copy link
Author

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

@listenzz
Copy link
Owner

listenzz commented May 7, 2022

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

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

@sharehoney
Copy link
Author

嗯嗯,谢谢。

@listenzz
Copy link
Owner

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

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

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants