簡體   English   中英

如何在Swift4中刪除TableView中的白線

[英]How to remove white line in tableview in swift4

我正在使用tableview來顯示值。但是在tableview中顯示了溫和的白線。 所有值顯示correctly.But 溫和的白線顯示在每一個細胞不是從實現代碼如下單元格中顯示table.This白線。

         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
    }


    }

在此處輸入圖片說明

我該如何刪除表格單元格中的白線。請幫助我

我相信您指的是單元格之間的分隔符。 那不是在細胞之間,而是在它們之間。 要禁用它們,只需設置以下內容:

tableView.separatorStyle = .none

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM