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

self.navigationController.navigationBar.lee_theme 不能立即生效, #24

Open
Arise903 opened this issue Oct 21, 2020 · 6 comments
Open

Comments

@Arise903
Copy link

@interface NewHotLineViewController : WMPageController h文件

以下是m文件 更改theme以后,下面的设置不能立即生效,需要左右滑动几次才能生效
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:NO animated:YES];

self.navigationController.navigationBar.lee_theme
.LeeAddCustomConfig(DAY , ^(UINavigationBar *item){
    [item setBackgroundImage:[UIImage imageWithColor:[UIColor clearColor]] forBarMetrics:UIBarMetricsDefault];
    item.barStyle = UIBarStyleDefault;
})
.LeeAddCustomConfig(NIGHT , ^(UINavigationBar *item){
    [item setBackgroundImage:[UIImage imageWithColor:RGBColor(55, 55, 55)] forBarMetrics:UIBarMetricsDefault];
    item.barStyle = UIBarStyleBlack;
});
@lixiang1994
Copy link
Owner

左右滑动是 导航栏的侧滑返回手势吗?

@Arise903
Copy link
Author

是的

@lixiang1994
Copy link
Owner

这和你直接在 -(void)viewWillAppear:(BOOL)animated中 设置

[self.navigationController.navigationBar setBackgroundImage:[UIImage imageWithColor:[UIColor clearColor]] forBarMetrics:UIBarMetricsDefault];
self.navigationController.navigationBar.barStyle = UIBarStyleDefault;

[self.navigationController.navigationBar setBackgroundImage:[UIImage imageWithColor:RGBColor(55, 55, 55)] forBarMetrics:UIBarMetricsDefault];
self.navigationController.navigationBar.barStyle = UIBarStyleBlack;

是相同的.
只不过会在主题发送变化时 再次出发block.

你似乎没有理解它的运行机制,

@yanmingLiu
Copy link

我这里是在基类的navc里面处理系统导航栏返回按钮的主题,问题出现在iOS12 iOS11上的在选择主题VC页面切换主题后返回按钮无法生效,不知道是不是系统导航栏的bug, 反正系统的导航栏始终有很多顽疾。我的处理方式是在选择主题页面隐藏系统导航写一个view去替换。

基类navc代码如下:

@implementation XXNavigationController

  • (void)viewDidLoad {
    [super viewDidLoad];
    [self.navigationBar setTranslucent:NO];

    self.navigationBar.lee_theme.LeeConfigBarTintColor(nav_barTint_color);

    self.navigationBar.lee_theme.LeeThemeChangingBlock(^(NSString * _Nonnull tag, UINavigationBar* bar) {
    DLog(@"tag = %@", tag);

      NSString *imageName;
      UIColor *titleColor;
      
      if ([tag isEqualToString:@"Light"]) {
          imageName = @"img_nav_back_light";
          titleColor = hex_666666;
          
      } else {
          imageName = @"img_nav_back_dark";
          titleColor = hex_FFFFFF;
      }
      bar.titleTextAttributes = @{NSForegroundColorAttributeName:titleColor,NSFontAttributeName :[UIFont boldSystemFontOfSize:15]};
    
      UIImage *backImage = [[UIImage imageNamed:imageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
      [bar setBackIndicatorImage:backImage];
      [bar setBackIndicatorTransitionMaskImage:backImage];
    

    });
    }

@lixiang1994
Copy link
Owner

你可以在block中打断点 确认一下切换后 是否执行了block中的代码, 如果执行了说明库本身没问题, 可能是系统导航栏的问题

@yanmingLiu
Copy link

你可以在block中打断点 确认一下切换后 是否执行了block中的代码, 如果执行了说明库本身没问题, 可能是系统导航栏的问题

block会执行2次,返回的主题tag也是正确的,iOS13以上也是没有问题的,可以确定的是库本身是没有问题的,系统导航栏确实很多问题,特别是针对中国特色设计。

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

3 participants