如何使用外观代理正确更改UITabBar的显示方式? [英] How can I correctly change the way a UITabBar appears using the appearance proxy?

查看:72
本文介绍了如何使用外观代理正确更改UITabBar的显示方式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于我正在开发iOS> = 5.0应用程序,我试图通过外观代理更改主UI组件的外观。

Since I am developing an iOS >= 5.0 application, I am trying to change the appearance of the main UI components through the appearance proxies.

处理时 UITabBar 组件,我正确地将其 tintColor 更改为浅灰色,通过 [[ UITabBar外观] setTintColor:] 方法。但是这样做,条形码中包含的 UITabBarItem 是很难看到的,因为它们在标题标签中保留了旧的灰色/白色。

When dealing with the UITabBar component, I correctly changed its tintColor to a light shade of gray trough the [[UITabBar appearance] setTintColor:] method. But doing this, the UITabBarItems included in the bar are quite impossible to see, since they retain the old gray/white color in their title label.

我试图通过 [UITabBarItem外观] 代理更改其外观,但无法使它们可见。

I tried to change their appearance through the [UITabBarItem appearance] proxy, but there is no way to make them visible.

有谁能建议我解决这个问题的方法?谢谢!

Can anyone suggest me a way to solve this problem? Thank you!

推荐答案

嗨这适用于你想做的事情

Hi this will work for what you want to do

// 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];

快乐编码:)

这篇关于如何使用外观代理正确更改UITabBar的显示方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆