【问题标题】:Xcode SwiftUI UITableView separator color form "section" textXcode SwiftUI UITableView 分隔颜色表单“部分”文本
【发布时间】:2021-06-05 07:57:06
【问题描述】:

Xcode 12 / Swift 5 / SwiftUI

如何在 NavigationView 内的表单中删除每个文本标签之间的分隔符?

我有这个,但每个文本之间还有一个分隔符,如何删除它?

struct ContentView: View {

    init() {
        UITableView.appearance().sectionHeaderHeight = .zero
        UITableView.appearance().backgroundColor = UIColor.white
        UITableView.appearance().separatorStyle = .none
    }

    var body: some View {

        NavigationView {

            Form {
                Section(){
                    Text("\(isbn ?? "")")
                    Text("\(foundBooks?.items.first?.volumeInfo.line1 ?? "")")
                    Text("\(foundBooks?.items.first?.volumeInfo.line2 ?? "")")
                    Text("\(foundBooks?.items.first?.volumeInfo.line3 ?? "")")
                    Text("\(foundBooks?.items.first?.volumeInfo.line4 ?? "")")
                    Text("\(foundBooks?.items.first?.volumeInfo.line5 ?? "")")
                    Text("\(foundBooks?.items.first?.volumeInfo.line6 ?? "")")
                }
            }
        }
    }
}

我虽然在 init 内部 UITableView.appearance().separatorStyle = .none 行会这样做,但它不会

添加什么代码以及在哪里删除每个Text()...之间的分隔符

【问题讨论】:

    标签: xcode forms swiftui sections navigationview


    【解决方案1】:

    挖了一下发现了这个

    Form {
                    Section(){
                        Text("\(isbn ?? "")")........
                    }.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .leading)
                    .listRowInsets(EdgeInsets())
                    .background(Color.white)
                }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-23
      • 2010-11-28
      • 1970-01-01
      • 2015-09-17
      相关资源
      最近更新 更多