由于我正在开发iOS> = 5.0应用程序,我试图通过外观代理更改主UI组件的外观。
在处理UITabBar
组件时,我通过tintColor
方法正确地将其[[UITabBar appearance] setTintColor:]
更改为浅灰色。但是这样做,栏中包含的UITabBarItem
是很难看到的,因为它们在标题标签中保留了旧的灰色/白色。
我尝试通过[UITabBarItem appearance]
代理更改其外观,但没有办法让它们可见。
有谁能建议我解决这个问题的方法?谢谢!
答案 0 :(得分:2)
嗨,这将适用于您想要做的事情
// Customize the UIBarButtonItem
UIImage *button30 = [[UIImage imageNamed:@"button_textured_30"]
resizableImageWithCapInsets:UIEdgeInsetsMake(0, 5, 0, 5)];
UIImage *button24 = [[UIImage imageNamed:@"button_textured_24"]
resizableImageWithCapInsets:UIEdgeInsetsMake(0, 5, 0, 5)];
[[UITabBarItem appearance] setBackgroundImage:button30 forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
[[UITabBarItem appearance] setBackgroundImage:button24 forState:UIControlStateNormal barMetrics:UIBarMetricsLandscapePhone];
[[UITabBarItem appearance] setTitleTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor colorWithRed:82.0/255.0
green:82.0/255.0
blue:82.0/255.0
alpha:1.0], UITextAttributeTextColor,
[UIColor colorWithRed:242.0
green:237.0
blue:237.0
alpha:1.0], UITextAttributeTextShadowColor,
[NSValue valueWithUIOffset:UIOffsetMake(0,1)], UITextAttributeTextShadowOffset,
[UIFont fontWithName:@"Helvetica" size:0.0], UITextAttributeFont,nil]
forState:UIControlStateNormal];
快乐编码:)