ios - 如何在swift4中删除tableview中的白线

标签 ios uitableview swift4

我正在使用 tableview 来显示值。但是在 tableview 中显示了轻微的白线。所有值都正确显示。但是 温和的白线 显示在表格中的每个单元格中。这条白线不会显示在 tableview 单元格中。

         func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat
    {
     var height:CGFloat!
            if (tableView == adventureTableView) {

            let width = UIScreen.main.bounds.size.width
            height = (width/640) * 410.0
            self.adventureTableView.tableHeaderView?.frame.size = CGSize(width: self.adventureTableView.tableHeaderView!.frame.size.width, height: height)


            }
            else  {

            let width = UIScreen.main.bounds.size.width
            height = (width/640) * 410.0
            self.adventureTableView.tableHeaderView?.frame.size = CGSize(width: self.adventureTableView.tableHeaderView!.frame.size.width, height: height)
            }

        return height

    }

    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {

        var count:Int = 0

            if (tableView == adventureTableView) {
                count =  adventure_nameArray.count
            }
            else  {
                count =  location_nameArray.count
            }

        return count

    }


 func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {




   if ( tableView == adventureTableView) {

        let cell = self.adventureTableView.dequeueReusableCell(withIdentifier: "travelcell") as! travelTableViewCell

        let adventure_name = self.adventure_nameArray[indexPath.row]
        self.adventure_favourite = self.adventure_favoriteArray[indexPath.row]
        self.adventure_favouriteCount = self.adventure_favoriteCountArray[indexPath.row]
          cell.travelcellImageView.image = self.adventure_imageDownloadArray[indexPath.row]

        cell.travelAventurename.text = adventure_name
        cell.travelFavouriteCount.text = String(adventure_favouriteCount)
        cell.travelFavouriteButton.tag = indexPath.row;

        if (adventure_favourite == 1){
            let img = UIImage(named: "like-hover.png")
            cell.travelFavouriteButton.setBackgroundImage(img, for: .normal)
        } else {
            let img = UIImage(named: "dislike.png")
            cell.travelFavouriteButton.setBackgroundImage(img, for: .normal)
        }

        cell.travelFavouriteButton.addTarget(self, action: #selector(advenureCellButtonAction), for: .touchUpInside)

   cell.travelAventurename.adjustsFontSizeToFitWidth = true


          return cell

    }

    else {



    let cell = self.locationTableView.dequeueReusableCell(withIdentifier: "locationcell") as! locationTableViewCell

        let location_name = self.location_nameArray[indexPath.row]
        self.location_favourite = self.location_favoriteArray[indexPath.row]
        self.location_favouriteCount = self.location_favoriteCountArray[indexPath.row]
           cell.locationcellImageView.image = self.location_imageDownloadArray[indexPath.row]


        cell.locationAventurename.text = location_name
        cell.locationFavouriteCount.text = String(location_favouriteCount)
        cell.locationFavouriteButton.tag = indexPath.row;




        if (location_favourite == 1){
            let img = UIImage(named: "like-hover.png")
            cell.locationFavouriteButton.setBackgroundImage(img, for: .normal)
        } else {
            let img = UIImage(named: "dislike.png")
            cell.locationFavouriteButton.setBackgroundImage(img, for: .normal)
        }


        cell.locationFavouriteButton.addTarget(self, action: #selector(locationCellButtonAction), for: .touchUpInside)


        cell.locationAventurename.sizeToFit()
        cell.locationFavouriteCount.sizeToFit()

     return cell
    }


    }

enter image description here

如何从 tableview 单元格中删除白线。请帮助我

最佳答案

我相信您指的是单元格之间的分隔符。那不在细胞中,而是在它们之间。要禁用它们,只需设置以下内容:

tableView.separatorStyle = .none

关于ios - 如何在swift4中删除tableview中的白线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48623124/

相关文章:

ios - [NSURLConnection sendAsynchronousRequest : . ..] 总是发送完成 block 吗?

arrays - 编辑数组中项目的最佳方法

ios - 如何处理ios应用程序的 ionic 无限重载

ios - 我可以使用 ARKit 2 测量眼睛吗

ios - ARKit 2 - 裁剪识别图像

ios - init() 在 Swift 4 的 AVCaptureDeviceInput 中不可用

ios - 如何将目标添加到 TableView 标题部分中的按钮

ios - UITableViewCell 中按钮的角不圆角

ios - 在不知道高度的情况下在单元格内异步下载图像

ios - 向下滚动时,无法再通过 [cell.contentView viewWithTag] 访问 UITableViewCell 元素