UITabbar 中的 item的字体颜色 item点击后的tint颜色 和图片颜色的修改 UINavigationBar字体设置
2015-04-16 09:58
483 查看
[[UITabBar appearance] setTintColor:[UIColor colorWithRed:0.0 green:176.0/255.0 blue:226.0/255.0 alpha:1.0]]; [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: [UIColor lightGrayColor], UITextAttributeTextColor, nil] forState:UIControlStateNormal];
UITabbar有个setTintColor这个方法,可以理解为,高亮的时候,或者点击后的颜色设置。
UITabBarItem有个setTitleTextAttributes的方法,是用来设置字体的颜色。
我这里是在viewDidLoad添加的。
代码如下:
//设置tabbar的背景图片 UITabBar *tabBar = self.tabBarController.tabBar; [tabBar setTintColor:[UIColor colorWithRed:0.0 green:176.0/255.0 blue:226.0/255.0 alpha:1.0]]; tabBar.selectedImageTintColor = [UIColor clearColor]; UITabBarItem *item = [tabBar.items objectAtIndex:0]; NSString *homePath = [[NSBundle mainBundle] pathForResource:@"btn_home_highlight" ofType:@"png"]; if(item.tag == 1) { [item setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: [UIColor lightGrayColor], UITextAttributeTextColor, nil] forState:UIControlStateNormal]; item.selectedImage = [UIImage imageWithContentsOfFile:homePath]; }
再看下面代码 UITabBarItem *tabBarItem1=self.tabBar.items[0]; UITabBarItem *tabBarItem2=self.tabBar.items[1]; tabBarItem1.image = [[UIImage imageNamed:@"iconAccount"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; tabBarItem1.selectedImage = [[UIImage imageNamed:@"iconAccountOn"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; tabBarItem2.image = [[UIImage imageNamed:@"iconFortune"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; tabBarItem2.selectedImage = [[UIImage imageNamed:@"iconFortuneOn"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; // tabBarItem2.badgeValue=@"10"; //设置正常状态字体 [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: [UIColor blackColor], NSForegroundColorAttributeName, nil] forState:UIControlStateNormal]; //设置选中状态字体 [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: [UIColor colorWithRed:255/255 green:56/255 blue:0 alpha:1.0], NSForegroundColorAttributeName, nil] forState:UIControlStateSelected]; // self.tabBar.tintColor=[UIColor colorWithRed:255/255 green:56/255 blue:0 alpha:1.0];
UINavigationBar设置title字体大小颜色 UINavigationBar *navBar = [UINavigationBar appearance]; [navBar setBackgroundColor:COLOR_MAKE(BACKGROUND_RED_VALUE, BACKGROUND_GREEN_VALUE, BACKGROUND_BLUE_VALUE)]; //修改navBar字体大小文字颜色 NSDictionary *attris = @{ NSFontAttributeName:[UIFont systemFontOfSize:NAV_TITLE_TEXT_SIZE], NSForegroundColorAttributeName:[UIColor blackColor] }; [navBar setTitleTextAttributes:attris];
导航栏颜色设置 if( ([[[UIDevice currentDevice] systemVersion] doubleValue]>=7.0)) { [[UINavigationBar appearance] setBarTintColor:[UIColor orangeColor]]; // [[UINavigationBar appearance] setTranslucent:NO]; } else { [[UINavigationBar appearance] setTintColor:[UIColor orangeColor]]; }
设置navigationItem 颜色self.navigationController.navigationBar.tintColor = [UIColor colorWithRed:0.0/255.0 green:205.0/255.0 blue:205.0/255.0 alpha:1.0]; 设置状态栏时间电池运营商颜色 (白色) info->Custom iOS Target Properties+ View controller-based status bar appearance 设置为NO [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; /** * 改变后需要及时刷新的调用 */ [self setNeedsStatusBarAppearanceUpdate];
相关文章推荐
- UITabbar 中的 item的字体颜色 item点击后的tint颜色 和图片颜色的修改
- iOS开发之--如何修改TabBarItem的title的字体和颜色/BarButtonItem的title的字体大小和颜色/添加背景图片,并添加点击方法
- Main.storyboard 和 如何修改Tab bar item 的图片、字体颜色 -
- 修改UITabBarItem的字体颜色
- 设置tabBarItem字体颜色和图片颜色
- android TextView、EditText对部分内容设置颜色、字体、超链接、图片、点击事件
- swift UITabBarItem修改字体颜色和图标颜色
- 给self.navigationItem.rightBarButtonItem设置字体颜色所引发的忧伤
- 设置TextView等View组件点击效果。点击修改背景。字体颜色等
- UITabBar,UITabBarItem怎么用字典设置UITabBarItem字体大小和颜色,保持原图颜色(item5)
- 修改UITabBarItem字体颜色
- iOS开发 在storyboard中拖的UITabBarController,设置选中时的图片和字体颜色
- UINavigationBar UITabBar UIBarButtonItem 图标显示原始颜色
- geiUItabBarItem设置图片颜色和title颜色
- iOS7集成设置UINavigationBar字体大小,风格,颜色
- navigationItem.rightBarButtonItem 设置背景图片,颜色更改解决的方法
- iOS小问题---设置TabBarItem的字体大小、颜色,各种状态下的图片
- 给self.navigationItem.rightBarButtonItem设置字体颜色
- 修改UITabBarController字体颜色 图片大小颜色的小问题
- ios 修改UITabBarItem字体颜色,正常与选中状态