美文网首页初见
swift中将UItabbar顶部线条隐藏

swift中将UItabbar顶部线条隐藏

作者: 你丫才码农 | 来源:发表于2017-04-06 21:55 被阅读320次
这是图片

方法一:

在TabBarController中的viewdidload()中添加:

       let TabBarLine = UITabBar.appearance()
      TabBarLine.shadowImage = UIImage()
      TabBarLine.backgroundImage = UIImage()

方法二:

在TabBarController中的viewdidload()中添加:

        self.tabBar.shadowImage = UIImage()
        self.tabBar.backgroundImage = initWithImage(color: UIColor(red: 246/255, green: 246/255, blue: 246/255, alpha: 0.8))

在TabBarController添加initWithImage():

  func initWithImage(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!
    } 

相关文章

网友评论

    本文标题:swift中将UItabbar顶部线条隐藏

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