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;
}

人已赞赏
iOS文章

iOS 获取设备型号

2020-4-30 4:48:02

iOS文章

iOS 暗黑模式全部关闭 or 某个界面关闭

2020-4-30 6:03:02

个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
有新消息 消息中心
搜索