gpt4 book ai didi

ios - 在 Tableview Swift 中删除 Header View Section 的白色边框底部

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:03:11 24 4
gpt4 key购买 nike

我将 Storyboard 中的分隔符样式删除为无,但标题 View 底部仍显示 1px 白色边框。我尝试将 viewdidload 上的分隔符样式设置为无,并尝试使用一些扩展来删除 subview ,但仍然不起作用。

我使用一个单元格在我的标题 View 中出列并为其设置高度。这是我的代码:

    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of rows
switch section {
case 0:
return 1
case 1:
return 1
case 2:
return 1
case 3:
return 1
case 4:
return 1
case 5:
return 1
case 6:
return 1
default:
return 1
}
}

// MARK: - View For Header

override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
switch section {
case 2:

let cell = tableView.dequeueReusableCell(withIdentifier: "NewProductHeaderTableViewCell") as! NewProductHeaderTableViewCell
tableView.separatorStyle = UITableViewCellSeparatorStyle.none
cell.titleLabel.text = "Produktet e reja"
return cell
case 3:
let cell = tableView.dequeueReusableCell(withIdentifier: "NewProductHeaderTableViewCell") as! NewProductHeaderTableViewCell
cell.titleLabel.text = "Top Produktet"
return cell
case 4:
let cell = tableView.dequeueReusableCell(withIdentifier: "NewProductHeaderTableViewCell") as! NewProductHeaderTableViewCell
cell.titleLabel.text = "Me te shiturat"
return cell
default:
return nil
}
}

// MARK: - Height For Header

override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
switch section {
case 2:
return 46.0
case 3:
return 46.0
case 4:
return 46.0
default:
return 0.1
}
}

override func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return 0
}

// MARK: - Height For Row

override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
switch indexPath.section {
case 0:
return 90
case 1:
return UITableViewAutomaticDimension
case 2:
return 177
case 3:
return 177
case 4:
return UITableViewAutomaticDimension
case 5:
return 90
case 6:
return 90
default:
return 90
}
}

// MARK: - Cell For Row

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

switch indexPath.section {
case 0:
let cell = tableView.dequeueReusableCell(withIdentifier: "StoryTableViewCell", for: indexPath) as! StoryTableViewCell
return cell
case 1:
return UITableViewCell()
case 2:
let cell = tableView.dequeueReusableCell(withIdentifier: "NewProductTableViewCell", for: indexPath) as! NewProductTableViewCell
return cell
case 3:
let cell = tableView.dequeueReusableCell(withIdentifier: "NewProductTableViewCell", for: indexPath) as! NewProductTableViewCell
return cell
case 4:
return UITableViewCell()
case 5:
return UITableViewCell()
case 6:
return UITableViewCell()
default:
return UITableViewCell()
}

}

enter image description here

最佳答案

试试这个:

cell.separatorInset = UIEdgeInsetsZero
cell.layoutMargins = UIEdgeInsetsZero

关于ios - 在 Tableview Swift 中删除 Header View Section 的白色边框底部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50108139/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com