iphone - 更改默认的 UITabBarController 背景颜色

标签 iphone objective-c uitabbarcontroller

所以我有一个运行的 iPhone 应用程序,它由 UITabBarController 在最高级别控制。这是您在许多 iPhone 应用程序中看到的底部默认的黑色标签栏。我是 iPhone SDK 编程的新手,我知道我看到其他应用程序在底部的选项卡栏有自己的背景颜色。我不确定他们是否像我一样使用这个标签栏作为他们应用程序的主 Controller ,但问题适用于此:

如何在我的应用程序中更改主 UITabBarController 的背景颜色?我想将其更改为深绿色阴影,类似于我在我的应用程序中放置的导航栏和标签的颜色。我觉得很奇怪 Apple 如何让更改导航栏(而不是 Controller )和其他东西的颜色变得非常容易,但是当涉及到 Controller (在本例中是 Tab Bar Controller)时,我找不到一种单一的方法来实现这干净高效。

最佳答案

你可以这样做。

- (void)viewDidLoad {
[super viewDidLoad];

CGRect frame = CGRectMake(0.0, 0, self.view.bounds.size.width, 48);

UIView *v = [[UIView alloc] initWithFrame:frame];

[v setBackgroundColor:[[UIColor alloc] initWithRed:1.0
                                           green:0.0
                                            blue:0.0
                                           alpha:0.1]];

[tabBar1 insertSubview:v atIndex:0];
[v release];
}

关于iphone - 更改默认的 UITabBarController 背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2375999/

相关文章:

iphone - 为什么我绘制 Core Graphics 三角形时它是倒转的?

iphone - 使用 UIRequiredDeviceCapabilities Corona SDK 将应用程序提交到 App Store 时出错

iphone - 以编程方式创建 UISwitch

ios - 自定义 UITableViewCell 选中时不显示内容

objective-c - 在标签栏应用程序中隐藏标签栏

ios - iOS 中的应用内购买有问题吗?

objective-c - NSView 中的 NSImage 旋转不起作用

objective-c - 等到后台选择器完成调用新方法

ios - UITabBarController 与 UIViewControllers 和 UITableViewControllers

swift - 标签栏的警报 View