3 回答

TA貢獻1995條經(jīng)驗 獲得超2個贊
我已經(jīng)能夠通過子類化UITabBarController并使用私有類來使其工作:
@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

TA貢獻1875條經(jīng)驗 獲得超3個贊
我有一個最終答案的附錄。雖然基本方案是正確的,但可以改進使用部分透明顏色的技巧。我假設它只是讓默認漸變顯示出來。哦,同樣,TabBar的高度是49像素而不是48像素,至少在OS 3中是這樣。
因此,如果你有一個帶有漸變的適當?shù)? x 49圖像,這是你應該使用的viewDidLoad的版本:
- (void)viewDidLoad {
[super viewDidLoad];
CGRect frame = CGRectMake(0, 0, 480, 49);
UIView *v = [[UIView alloc] initWithFrame:frame];
UIImage *i = [UIImage imageNamed:@"GO-21-TabBarColorx49.png"];
UIColor *c = [[UIColor alloc] initWithPatternImage:i];
v.backgroundColor = c;
[c release];
[[self tabBar] addSubview:v];
[v release];
}
- 3 回答
- 0 關注
- 1080 瀏覽
添加回答
舉報