您的位置:首页 > 产品设计 > UI/UE

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];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: