美文网首页IOS 学习
OC-UITabBar上相关设置

OC-UITabBar上相关设置

作者: SK丿希望 | 来源:发表于2019-03-27 10:31 被阅读0次
    • 去掉黑线
    [UITabBar appearance].barStyle = UIBarStyleBlack;
    
    • 自定义黑线颜色
    CGRect rect = CGRectMake(0, 0, [UIApplication sharedApplication].keyWindow.bounds.size.width, 1);
    UIGraphicsBeginImageContext(rect.size);
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetFillColorWithColor(context, [UIColor redColor].CGColor);
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    [UITabBar appearance].shadowImage = image;
    
    • 设置背景色
    [UITabBar appearance].backgroundColor = hw_BGColor;
    
    • 自定义背景图片
    [UITabBar appearance].backgroundImage = [UIImage imageNamed:@"TabBar_BG"];
    
    • 设置字体偏移
    [UITabBarItem appearance].titlePositionAdjustment = UIOffsetMake(0.0,0.0);
    
    • 字体
    [[UITabBarItem appearance] setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:15]} forState:UIControlStateNormal];
    
    • 未选中颜色
    [[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:self.normalColor} forState:UIControlStateNormal];
    
    • 选中颜色
    [[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:self.selectColor} forState:UIControlStateSelected];
    

    注意:有点设置无限需要将[UITabBar appearance].translucent = YES;才可以

    • NavigationController 隐藏黑线
    self.navigationBar.barStyle = UIBaselineAdjustmentNone;
    

    相关文章

      网友评论

        本文标题:OC-UITabBar上相关设置

        本文链接:https://www.haomeiwen.com/subject/jsvavqtx.html