ios - 在 Tableview Swift 中删除 Header View Section 的白色边框底部
<p><p>我将 Storyboard 中的分隔符样式删除为 none,但标题 View 底部仍显示 1px 白色边框。
我尝试将 viewdidload 上的分隔符样式设置为 none,并尝试使用一些扩展来删除 subview ,但仍然不起作用。</p>
<p>我使用一个单元格在我的标题 View 中出列并为其设置高度。
这是我的代码:</p>
<pre><code> 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()
}
}
</code></pre>
<p> <a href="/image/G5DQU.png" rel="noreferrer noopener nofollow"><img src="/image/G5DQU.png" alt="enter image description here"/></a> </p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>试试这个:</p>
<pre><code>cell.separatorInset = UIEdgeInsetsZero
cell.layoutMargins = UIEdgeInsetsZero
</code></pre></p>
<p style="font-size: 20px;">关于ios - 在 Tableview Swift 中删除 Header View Section 的白色边框底部,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/50108139/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/50108139/
</a>
</p>
页:
[1]