自定義UITabBarController的tabBar背景圖片
新建一個類繼承UITabBarController:
- (id) init
{
self = [super init];
if (self) {
//方法一
UIImageView *img = [[UIImageViewalloc] initWithImage:[UIImageimageNamed:@"bg.png"]];
img.frame = CGRectMake(0, 0, self.tabBar.frame.size.width, self.tabBar.frame.size.height);
img.contentMode
//img.frame = CGRectOffset(img.frame, 0, 1);
[[selftabBar] insertSubview:img atIndex:0];
[img release];
//方法二
CGRect frame = CGRectMake(0, 0, self.view.bounds.size.width, 49);
UIView *view = [[UIView alloc] initWithFrame:frame];
UIImage
UIColor *color = [[UIColor alloc] initWithPatternImage:tabBarBackgroundImage];
[view setBackgroundColor:color];
[color release];
[[selftabBar] insertSubview:view atIndex:0];
[view release];
}
returnself;
}