我正在使用 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
}
}
如何从 tableview 单元格中删除白线。请帮助我
最佳答案
我相信您指的是单元格之间的分隔符。那不在细胞中,而是在它们之间。要禁用它们,只需设置以下内容:
tableView.separatorStyle = .none
关于ios - 如何在swift4中删除tableview中的白线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48623124/