Tabbar

iOS-修改系统Tabbar背景色

2016-06-12  本文已影响2489人  一位不愿透露姓名的王先生_
1. 系统默认情况(见下图):
tabBar系统默认颜色.png
2. 自定义 tabBar 背景色效果(见下图):
自定义tabBar背景色.png
3. 代码如下:
    // 设置一个自定义 View,大小等于 tabBar 的大小
    UIView *bgView = [[UIView alloc] initWithFrame:self.tabBar.bounds];
    // 给自定义 View 设置颜色
    bgView.backgroundColor = [UIColor redColor];
    // 将自定义 View 添加到 tabBar 上
    [self.tabBar insertSubview:bgView atIndex:0];
注意:
  1. 以上代码要写在 appdelegate.m- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions方法里面
上一篇 下一篇

猜你喜欢

热点阅读