uitableview - 在文本之前列出分隔符的奇怪行
问题描述
似乎无法弄清楚这件事。在我的列表中,我在文本之前有这些白色(暗模式下为黑色)线条,我无法摆脱它们。有人告诉我,这意味着我编码错误。但它是什么?这是我的代码:
import SwiftUI
struct ContentView: View {
init(){
UITableView.appearance().backgroundColor = .clear
}
var body: some View {
List {
Text("List Item 1").listRowBackground(Color("customColor"))
Text("List Item 2").listRowBackground(Color("customColor"))
Text("List Item 3").listRowBackground(Color("customColor"))
Text("List Item 4").listRowBackground(Color("customColor"))
Text("List Item 5").listRowBackground(Color("customColor"))
}.background(Color("customColor"))
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
然后在 appDelegates (didFinishLaunchingWithOptions) 我把这个:
UITableView.appearance().separatorColor = .darkGray.
发现了几个关于列表背景颜色的主题,但在那些主题中似乎没有人关心这些烦人的线条。我该怎么做才能摆脱它们?
解决方案
SwiftUI 2.0
无需更改 - 按原样工作
SwiftUI 1.0+
这是一个修复(使用 Xcode 11.4 / iOS 13.4 测试)
UITableViewCell.appearance().backgroundColor = .clear // << add this one !!
UITableView.appearance().backgroundColor = .clear
推荐阅读
- javascript - 为什么 jquery.blockUI 会吞下 onClick 事件?
- ios - iOS 移动应用程序无法识别 SQLiteStudio 中的表更新
- c++ - 如何在 Linux 上检测 CDRom 是否是 DVD
- spring-boot - Spring Boot Java 11 应用程序不会部署在谷歌云中
- unit-testing - 如何为速度模板编写单元测试?
- sql - 条件仅提取过去三个月内某个帐号中某人为某个类别拨打超过 2 次的记录
- android - Android Studio - ndk_build_command 在清理任务上失败
- excel - 在 Python 中迭代两个列表
- serialization - 对象指纹:序列化 + 不可触碰的遗留代码 + Getter-only 自动属性 = 走投无路?
- c# - MonthCalendar DateSelected 事件未触发,我需要在选择任何单个日期时执行代码