导航栏属性设置:
//背景色
[self.navigationBar setBackgroundImage:[Tools InitImageWithColor:themeColor size:CGSizeMake(ScreenWidth, NaviHight)] forBarMetrics:UIBarMetricsDefault];
//字体颜色和大小
[self.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor],NSFontAttributeName:sysBfont(18)}];
//状态栏默认为白色
self.navigationBar.barStyle=UIBarStyleDefault;
if (@available(iOS 13.0, *)) {
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
[dict setObject:syswhiteColor forKey:NSForegroundColorAttributeName];
[dict setObject:sysBfont(18) forKey:NSFontAttributeName];
UINavigationBarAppearance *appearance = [[UINavigationBarAppearance alloc] init];
[appearance setBackgroundColor:themeColor];
appearance.titleTextAttributes = dict;
[[UINavigationBar appearance] setScrollEdgeAppearance: appearance];
[[UINavigationBar appearance] setStandardAppearance:appearance];
}
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
[dict setObject:syswhiteColor forKey:NSForegroundColorAttributeName];
[dict setObject:sysBfont(18) forKey:NSFontAttributeName];
[[UINavigationBar appearance] setTitleTextAttributes:dict];
分栏属性设置:
[UITabBar appearance].translucent = NO;//取消透明
[[UITabBar appearance] setBarTintColor:[UIColor whiteColor]];
if (@available(iOS 15.0, *)) {
UITabBar *tabBar = [UITabBar appearance];
[tabBar setTintColor:themeColor];
[tabBar setUnselectedItemTintColor:[Tools hexStringToColor:@"999999"]];
}
else
{
//未选中
NSDictionary *defaultAttribute=@{NSForegroundColorAttributeName:[Tools hexStringToColor:@"999999"],NSFontAttributeName:[UIFont systemFontOfSize:12]};
[[UITabBarItem appearance]setTitleTextAttributes:defaultAttribute forState:UIControlStateNormal];
//选中
NSDictionary *SelectAttribute=@{NSForegroundColorAttributeName:themeColor,NSFontAttributeName:[UIFont systemFontOfSize:12]};
[[UITabBarItem appearance]setTitleTextAttributes:SelectAttribute forState:UIControlStateSelected];
}