美文网首页
去除tabbar顶部的横线

去除tabbar顶部的横线

作者: 蛋哥是只猫 | 来源:发表于2019-06-11 15:18 被阅读0次

在使用tabbar的时候系统会自动的在顶端添加一条横线,项目中需要去除可以将tabarshadowImage设置为你想要的背景图片,我是将颜色直接转换成了一张图片替换了,需要注意的是直接赋值一张空图片如:self.tabBar.shadowImage = UIImage()是不能成功的去除掉的

  self.tabBar.shadowImage = UIColor.white.toImage()

这是我们项目中用到的一个将UIColor转化为UIImage的方法

  func toImage() -> UIImage {
        let rect = CGRect(x: 0, y: 0, width: 1, height: 1)
        UIGraphicsBeginImageContextWithOptions(rect.size, false, 0)
        self.setFill()
        UIRectFill(rect)
        let image = UIGraphicsGetImageFromCurrentImageContext()
        UIGraphicsEndImageContext()
        return image!
    }

相关文章

网友评论

      本文标题:去除tabbar顶部的横线

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