Tencent / QMUI_iOS

QMUI iOS——致力于提高项目 UI 开发效率的解决方案
http://qmuiteam.com/ios
Other
7.08k stars 1.38k forks source link

UITabBarItem 切换主题的时候,图片没有切换 #1254

Closed YuanJiaShuai closed 3 years ago

YuanJiaShuai commented 3 years ago

QMUI 已经提供了详尽的注释文档,以及完整的示例项目 QMUI Demo,当你遇到某些功能不知道怎么使用,或者想知道 QMUI 是否有提供某些功能时,请先查看注释文档或者 Demo,找不到了再提 issue。若提的 issue 已有明确注释或示例的,可能会被直接关闭或得不到及时的回复,请知悉。

我现在使用QMUI 实现换肤功能,遇到了一个问题,就是配置了UITabBarItem 的暗色皮肤的图片,和亮色版本的图片,但是当切换皮肤的时候,UITabBar 的图片不会自动切换,需要重现启动一下app才正常

// QMUIKit
    QDUIKitViewController *uikitViewController = [[QDUIKitViewController alloc] init];
    uikitViewController.hidesBottomBarWhenPushed = NO;
    QDNavigationController *uikitNavController = [[QDNavigationController alloc] initWithRootViewController:uikitViewController];
    uikitNavController.tabBarItem = [QDUIHelper tabBarItemWithTitle:@"QMUIKit" image:UIImageMake(@"icon_tabbar_uikit") selectedImage:UIImageMake(@"icon_tabbar_uikit_selected") tag:0];
    AddAccessibilityHint(uikitNavController.tabBarItem, @"展示一系列对系统原生控件的拓展的能力");

    // UIComponents
    UIImage *image = [UIImage qmui_imageWithThemeProvider:^UIImage * _Nonnull(__kindof QMUIThemeManager * _Nonnull manager, NSString * _Nullable identifier, NSObject<QDThemeProtocol> * _Nullable theme) {
        if([identifier isEqualToString:@"Dark"]){
            //暗黑TaBar img
            return UIImageMake(@"bot_ic_hangqing_d_dark");
        }else{
            return UIImageMake(@"icon_tabbar_uikit");
        }
    }];

    QDComponentsViewController *componentViewController = [[QDComponentsViewController alloc] init];
    componentViewController.hidesBottomBarWhenPushed = NO;
    QDNavigationController *componentNavController = [[QDNavigationController alloc] initWithRootViewController:componentViewController];
    componentNavController.tabBarItem = [QDUIHelper tabBarItemWithTitle:@"Components" image:image selectedImage:UIImageMake(@"icon_tabbar_component_selected") tag:1];
    AddAccessibilityHint(componentNavController.tabBarItem, @"展示 QMUI 自己的组件库");

这是我使用QD里面的代码,自己更改的部分代码,图片是我自己上传了一份,这样写不生效,希望大佬能帮我指点指点