From 7b1e6baabb13d7872a01c41c89ffd94db2d0c171 Mon Sep 17 00:00:00 2001 From: LEE <18611401994@163.com> Date: Sat, 28 May 2022 18:18:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0Demo=20UITabBar=E5=92=8CUINav?= =?UTF-8?q?igationBar=E9=80=82=E9=85=8DiOS15=E7=9A=84=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E6=96=B9=E5=BC=8F=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LEEThemeDemo.xcodeproj/project.pbxproj | 5 +- LEEThemeDemo/LEEThemeDemo/TabBarController.m | 115 +++++++++++++++--- 2 files changed, 97 insertions(+), 23 deletions(-) diff --git a/LEEThemeDemo/LEEThemeDemo.xcodeproj/project.pbxproj b/LEEThemeDemo/LEEThemeDemo.xcodeproj/project.pbxproj index fa1f39a..cc6e565 100644 --- a/LEEThemeDemo/LEEThemeDemo.xcodeproj/project.pbxproj +++ b/LEEThemeDemo/LEEThemeDemo.xcodeproj/project.pbxproj @@ -2625,7 +2625,6 @@ TargetAttributes = { 9B00492F1CC9CE25001AC212 = { CreatedOnToolsVersion = 7.3; - DevelopmentTeam = 5KA67R3283; ProvisioningStyle = Automatic; SystemCapabilities = { com.apple.Push = { @@ -3190,7 +3189,7 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = 5KA67R3283; + DEVELOPMENT_TEAM = MHW5BL2Z4W; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/LEEThemeDemo/YYKitDemo/Vendor", @@ -3218,7 +3217,7 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = 5KA67R3283; + DEVELOPMENT_TEAM = MHW5BL2Z4W; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/LEEThemeDemo/YYKitDemo/Vendor", diff --git a/LEEThemeDemo/LEEThemeDemo/TabBarController.m b/LEEThemeDemo/LEEThemeDemo/TabBarController.m index 1fc840d..23c1932 100644 --- a/LEEThemeDemo/LEEThemeDemo/TabBarController.m +++ b/LEEThemeDemo/LEEThemeDemo/TabBarController.m @@ -37,10 +37,40 @@ - (void)initData{ - (void)configTheme { - self.tabBar.lee_theme - .LeeAddBarTintColor(DAY , LEEColorRGB(255, 255, 255)) - .LeeAddBarTintColor(NIGHT , LEEColorRGB(40, 40, 40)) - .LeeConfigBarTintColor(@"ident1"); + self.tabBar.lee_theme.LeeThemeChangingBlock(^(NSString * _Nonnull tag, UITabBar * _Nonnull item) { + + // 适配iOS 15的设置方式 + if (@available(iOS 13.0, *)){ + UITabBarAppearance *appearance = [[UITabBarAppearance alloc] init]; + + [appearance configureWithOpaqueBackground]; + + if ([tag isEqualToString:DAY]) { + appearance.backgroundColor = LEEColorRGB(255, 255, 255); + + } else if ([tag isEqualToString:NIGHT]) { + appearance.backgroundColor = LEEColorRGB(40, 40, 40); + + } else { + + appearance.backgroundColor = [LEETheme getValueWithTag:tag Identifier:@"ident1"]; + } + + item.standardAppearance = appearance; + + if (@available(iOS 15.0, *)){ + item.scrollEdgeAppearance = appearance; + } + + } else { + item.barTintColor = [LEETheme getValueWithTag:tag Identifier:@"ident1"]; + } + }); + +// self.tabBar.lee_theme +// .LeeAddBarTintColor(DAY , LEEColorRGB(255, 255, 255)) +// .LeeAddBarTintColor(NIGHT , LEEColorRGB(40, 40, 40)) +// .LeeConfigBarTintColor(@"ident1"); } - (void)initSubControllers{ @@ -59,25 +89,70 @@ - (void)initSubControllers{ nc = [[UINavigationController alloc] initWithRootViewController:[[NSClassFromString(classArray[i])alloc] init]]; - nc.navigationBar.lee_theme - .LeeAddBarTintColor(DAY , LEEColorRGB(255, 255, 255)) - .LeeAddBarTintColor(NIGHT , LEEColorRGB(85, 85, 85)) - .LeeConfigBarTintColor(@"ident1"); - - nc.navigationBar.lee_theme - .LeeAddCustomConfig(DAY, ^(UINavigationBar *bar) { - - bar.titleTextAttributes = @{NSForegroundColorAttributeName : [UIColor blackColor]}; - }) - .LeeAddCustomConfig(NIGHT, ^(UINavigationBar *bar) { + // 适配iOS 15的设置方式 + nc.navigationBar.lee_theme.LeeThemeChangingBlock(^(NSString * _Nonnull tag, UINavigationBar * _Nonnull item) { - bar.titleTextAttributes = @{NSForegroundColorAttributeName : [UIColor whiteColor]}; - }) - .LeeCustomConfig(@"ident7", ^(UINavigationBar *bar, id value) { - - bar.titleTextAttributes = @{NSForegroundColorAttributeName : value}; + if (@available(iOS 13.0, *)){ + UINavigationBarAppearance *appearance = [[UINavigationBarAppearance alloc] init]; + [appearance configureWithOpaqueBackground]; + + if ([tag isEqualToString:DAY]) { + appearance.titleTextAttributes = @{NSForegroundColorAttributeName : [UIColor blackColor]}; + + appearance.backgroundColor = LEEColorRGB(255, 255, 255); + + } else if ([tag isEqualToString:NIGHT]) { + appearance.titleTextAttributes = @{NSForegroundColorAttributeName : [UIColor whiteColor]}; + + appearance.backgroundColor = LEEColorRGB(85, 85, 85); + + } else { + appearance.titleTextAttributes = @{NSForegroundColorAttributeName : [LEETheme getValueWithTag:tag Identifier:@"ident7"]}; + + appearance.backgroundColor = [LEETheme getValueWithTag:tag Identifier:@"ident1"]; + } + + item.standardAppearance = appearance; + + if (@available(iOS 15.0, *)){ + item.scrollEdgeAppearance = appearance; + } + + } else { + + if ([tag isEqualToString:DAY]) { + item.titleTextAttributes = @{NSForegroundColorAttributeName : [UIColor blackColor]}; + + } else if ([tag isEqualToString:NIGHT]) { + item.titleTextAttributes = @{NSForegroundColorAttributeName : [UIColor whiteColor]}; + + } else { + item.titleTextAttributes = [LEETheme getValueWithTag:tag Identifier:@"ident7"]; + } + + item.barTintColor = [LEETheme getValueWithTag:tag Identifier:@"ident1"]; + } }); +// nc.navigationBar.lee_theme +// .LeeAddBarTintColor(DAY , LEEColorRGB(255, 255, 255)) +// .LeeAddBarTintColor(NIGHT , LEEColorRGB(85, 85, 85)) +// .LeeConfigBarTintColor(@"ident1"); + +// nc.navigationBar.lee_theme +// .LeeAddCustomConfig(DAY, ^(UINavigationBar *bar) { +// +// bar.titleTextAttributes = @{NSForegroundColorAttributeName : [UIColor blackColor]}; +// }) +// .LeeAddCustomConfig(NIGHT, ^(UINavigationBar *bar) { +// +// bar.titleTextAttributes = @{NSForegroundColorAttributeName : [UIColor whiteColor]}; +// }) +// .LeeCustomConfig(@"ident7", ^(UINavigationBar *bar, id value) { +// +// bar.titleTextAttributes = @{NSForegroundColorAttributeName : value}; +// }); + nc.tabBarItem.title = nameArray[i]; }