iOS 关于iOS13 tabbar item的字体颜色问题 隐藏黑线 修改tabbar高度.....

在这里插入图片描述
兄弟们 雨过地皮湿呀

tabbar item title颜色

        if #available(iOS 13, *) {
            UITabBar.appearance().unselectedItemTintColor = UIColor.init(0xA6C0D4);
            self.tabBar.tintColor = UIColor.init(0x6979F8);
        } else {
            viewCon.tabBarItem.setTitleTextAttributes([NSAttributedString.Key.foregroundColor :UIColor.init(0x6979F8)], for: UIControl.State.selected)
            viewCon.tabBarItem.setTitleTextAttributes([NSAttributedString.Key.foregroundColor :UIColor.init(0xB5B8D0)], for: UIControl.State.normal)
        }

关闭图片渲染

    /// 根据图片名称 获取不被渲染的image
    func imgGet(imgName:String) -> UIImage {
        return (UIImage.init(named:imgName)?.withRenderingMode(UIImage.RenderingMode.alwaysOriginal))!
    }

隐藏tabbar的黑线

      方法1 用view遮挡
        let bgView = UIView.init(frame: self.view.bounds)
        bgView.frame.origin.y = -1
        bgView.backgroundColor = UIColor.white
        self.tabBar.insertSubview(bgView, at: 0)
        
  //方法2 透明img
        if #available(iOS 13, *) { 
            let appearance = tabBar.standardAppearance.copy()
            appearance.backgroundImage = self.getImageWithColor(color: .clear)
           appearance.shadowImage = self.getImageWithColor(color: .clear)
            tabBar.standardAppearance = appearance
        } else {
          //取掉tabbar的黑线
          self.tabBar.backgroundImage = UIImage.init()
          self.tabBar.shadowImage = UIImage.init()
        }

    /// 将颜色转换为图片
    ///
    /// - Parameter color: UIColor
    /// - Returns: UIImage
    func getImageWithColor(color:UIColor)->UIImage {
        let rect = CGRect(x: 0, y: 0, width: 1, height: 1)
        UIGraphicsBeginImageContext(rect.size)
        let context = UIGraphicsGetCurrentContext()
        context!.setFillColor(color.cgColor)
        context!.fill(rect)
        let image = UIGraphicsGetImageFromCurrentImageContext()
        UIGraphicsEndImageContext()
        return image!
    }

修改tabbar的高度

- (void)viewDidLayoutSubviews {
    CGRect tabFrame = self.tabBar.frame;
    tabFrame.size.height = 73 + LL_TabbarSafeBottomMargin;
    tabFrame.origin.y = self.view.frame.size.height - 73  - LL_TabbarSafeBottomMargin ;
    self.tabBar.frame = tabFrame;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值