如何正确更改使用外观代理的UITabBar的显示方式?
问题描述:
由于我正在开发iOS> = 5.0应用程序,因此我试图通过外观代理来更改主UI组件的外观。如何正确更改使用外观代理的UITabBar的显示方式?
当处理UITabBar
组件时,我通过[[UITabBar appearance] setTintColor:]
方法正确地将其tintColor
更改为浅灰色。但是这样做,酒吧里包含的UITabBarItem
是很难看到的,因为它们在标题标签中保留了旧的灰色/白色。
我试图通过[UITabBarItem appearance]
代理更改外观,但无法使其可见。
任何人都可以建议我一种方法来解决这个问题吗?谢谢!
答
你好,这会为你想要做
// 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];
编码快乐:)
我认为'setTitleTextAttributes什么工作:'方法是只在iOS> = 6.0可用。这两个图像是什么样子的? – marzapower
这些用于设置为按钮 –
的背景图像我认为您应该用'UITabBarItem'将'UIBarButtonItem'更改为此解决方案的工作。 – marzapower