我正在尝试使用以下代码自定义UITabbar而没有任何运气:
这是我的viewDidLoad方法
UIImage *tabBackground = [[UIImage imageNamed:@"tabbar.png"]
resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
// Set background for all UITabBars
[[UITabBar appearance] setBackgroundImage:tabBackground];
// Set background for only this UITabBar
[[self.tabBarController tabBar] setBackgroundImage:tabBackground];
任何想法我可能会在哪里出错?感谢
答案 0 :(得分:1)
我们可以改变UITabBar控制器的背景颜色。请参考下面给出的代码。希望这对你有帮助。
tabBar1.backgroundColor = [UIColor clearColor];
CGRect frame = CGRectMake(0, 0, 480, 49);
UIView *view = [[UIView alloc] initWithFrame:frame];
UIImage *image = [UIImage imageNamed:@"Image.png"];
UIColor *color = [[UIColor alloc] initWithPatternImage:image];
view.backgroundColor = color;
[color release];
[[self tabBar] insertSubview:view atIndex:0];
[view release];