GithubHelp home page GithubHelp logo

暗黑模式 about zxnavigationbar HOT 3 CLOSED

smilezxlee avatar smilezxlee commented on May 24, 2024
暗黑模式

from zxnavigationbar.

Comments (3)

SmileZXLee avatar SmileZXLee commented on May 24, 2024

我看标题是可以正常响应的,但是leftBtn和rightBtn会很奇怪,有的时候能响应,有的时候不能响应。

可以提供一下暗黑模式下您对ZXNavigationBar属性设置的代码吗,感谢!

from zxnavigationbar.

myDonghao avatar myDonghao commented on May 24, 2024

现在我是在暗黑模式切换的通知里面,重新设置了一下左右按钮的颜色。

- (void)handleThemeDidChangeNotification:(NSNotification *)notification {
    self.zx_navLeftBtn.zx_imageColor = self.zx_navTintColor;
    self.zx_navRightBtn.zx_imageColor = self.zx_navTintColor;
    self.zx_navSubRightBtn.zx_imageColor = self.zx_navTintColor;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.zx_navStatusBarStyle = ZXNavStatusBarStyleDefault;
    self.view.backgroundColor = UIColor.qd_backgroundColor;
    self.zx_navBar.backgroundColor = UIColor.qd_backgroundColor;
    self.zx_navTintColor = [UIColor qmui_colorWithThemeProvider:^UIColor * _Nonnull(__kindof QMUIThemeManager * _Nonnull manager, __kindof NSObject<NSCopying> * _Nullable identifier, __kindof NSObject * _Nullable theme) {
        if ([identifier isEqual:QDThemeIdentifierDark]) {
            return [UIColor whiteColor];
        } else {
            return [UIColor darkGrayColor];
        }
    }];
    self.zx_navBar.lineView.hidden = YES;
    self.zx_navLeftBtn.zx_imageColor = self.zx_navTintColor;
    self.zx_navRightBtn.zx_imageColor = self.zx_navTintColor;
    
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleThemeDidChangeNotification:) name:QMUIThemeDidChangeNotification object:nil];
}

from zxnavigationbar.

SmileZXLee avatar SmileZXLee commented on May 24, 2024

现在我是在暗黑模式切换的通知里面,重新设置了一下左右按钮的颜色。

- (void)handleThemeDidChangeNotification:(NSNotification *)notification {
    self.zx_navLeftBtn.zx_imageColor = self.zx_navTintColor;
    self.zx_navRightBtn.zx_imageColor = self.zx_navTintColor;
    self.zx_navSubRightBtn.zx_imageColor = self.zx_navTintColor;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.zx_navStatusBarStyle = ZXNavStatusBarStyleDefault;
    self.view.backgroundColor = UIColor.qd_backgroundColor;
    self.zx_navBar.backgroundColor = UIColor.qd_backgroundColor;
    self.zx_navTintColor = [UIColor qmui_colorWithThemeProvider:^UIColor * _Nonnull(__kindof QMUIThemeManager * _Nonnull manager, __kindof NSObject<NSCopying> * _Nullable identifier, __kindof NSObject * _Nullable theme) {
        if ([identifier isEqual:QDThemeIdentifierDark]) {
            return [UIColor whiteColor];
        } else {
            return [UIColor darkGrayColor];
        }
    }];
    self.zx_navBar.lineView.hidden = YES;
    self.zx_navLeftBtn.zx_imageColor = self.zx_navTintColor;
    self.zx_navRightBtn.zx_imageColor = self.zx_navTintColor;
    
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleThemeDidChangeNotification:) name:QMUIThemeDidChangeNotification object:nil];
}

您好,感谢您的协助,self.zx_navTintColor用于设置导航栏标题文字颜色+左右按钮图片颜色+左右按钮文字颜色,也就是说,您通过设置self.zx_navTintColor = [UIColor redColor]即可将导航栏标题颜色和左右按钮图片颜色设置为红色,self.zx_navLeftBtn.zx_imageColor用户在此基础上,覆盖设置颜色(比如需要将左侧按钮图片颜色单独设置成黄色),因此根据您的需求,您只需要作以下调整即可:

- (void)handleThemeDidChangeNotification:(NSNotification *)notification {
    //如果是暗黑模式
   self.zx_navTintColor = 暗黑模式下的颜色;
   //如果不是暗黑模式
   self.zx_navTintColor = 普通模式下的颜色;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    //默认是ZXNavStatusBarStyleDefault,如果全局都是ZXNavStatusBarStyleDefault,这一行也可以去掉
    //self.zx_navStatusBarStyle = ZXNavStatusBarStyleDefault;
    self.view.backgroundColor = UIColor.qd_backgroundColor;
    self.zx_navBar.backgroundColor = UIColor.qd_backgroundColor;
    self.zx_navTintColor = [UIColor qmui_colorWithThemeProvider:^UIColor * _Nonnull(__kindof QMUIThemeManager * _Nonnull manager, __kindof NSObject<NSCopying> * _Nullable identifier, __kindof NSObject * _Nullable theme) {
        if ([identifier isEqual:QDThemeIdentifierDark]) {
            return [UIColor whiteColor];
        } else {
            return [UIColor darkGrayColor];
        }
    }];
    self.zx_navBar.lineView.hidden = YES;
   
    //以下两行代码不需要设置,可以去掉
    //self.zx_navLeftBtn.zx_imageColor = self.zx_navTintColor;
    //self.zx_navRightBtn.zx_imageColor = self.zx_navTintColor;
    
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleThemeDidChangeNotification:) name:QMUIThemeDidChangeNotification object:nil];
}

您可以根据上述事例调整一下您的代码,若有任何问题欢迎随时在issue中回复我,感谢!

from zxnavigationbar.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.