我在Silent Mac Design找到了答案。
我這樣實現(xiàn):
首先創(chuàng)建UITabBarContoller的子類
// CustomUITabBarController.h#import <UIKit/UIKit.h>@interface CustomUITabBarController: UITabBarController {
IBOutlet UITabBar *tabBar1;}@property(nonatomic, retain) UITabBar *tabBar1;@end
// CustomUITabBarController.m#import "CustomUITabBarController.h"@implementation CustomUITabBarController@synthesize tabBar1;- (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];}@end
在你的Nib文件中用CustomUITabBarController替換你的TabBar控制器的類。