改变UITabBar的色调/背景颜色 [英] Changing Tint / Background color of UITabBar

查看:95
本文介绍了改变UITabBar的色调/背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

UINavigationBar和UISearchBar都有一个tintColor属性,允许你改变这两个项目的色调(我知道)。我想在我的应用程序中对UITabBar做同样的事情,但现在已经找到了从默认的黑色中改变它的方法。任何想法?

The UINavigationBar and UISearchBar both have a tintColor property that allows you to change the tint color (surprising, I know) of both of those items. I want to do the same thing to the UITabBar in my application, but have found now way to change it from the default black color. Any ideas?

推荐答案

我已经能够通过继承UITabBarController并使用私有类来实现它:

I have been able to make it work by subclassing a UITabBarController and using private classes:

@interface UITabBarController (private)
- (UITabBar *)tabBar;
@end

@implementation CustomUITabBarController


- (void)viewDidLoad {
    [super viewDidLoad];

    CGRect frame = CGRectMake(0.0, 0.0, self.view.bounds.size.width, 48);
    UIView *v = [[UIView alloc] initWithFrame:frame];
    [v setBackgroundColor:kMainColor];
    [v setAlpha:0.5];
    [[self tabBar] addSubview:v];
    [v release];

}
@end

这篇关于改变UITabBar的色调/背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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