swift中将UItabbar顶部线条隐藏

swift中将UItabbar顶部线条隐藏_第1张图片
这是图片

方法一:

在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顶部线条隐藏)