[英]How to remove right left padding of `Form` in SwiftUI?
如何去除SwiftUI中Form的左右填充? 我創建的每個視圖在前導和尾隨都有填充。
這是我的代碼
init() {
UITableView.appearance().tableHeaderView = UIView(frame: CGRect(x: 0, y: 0, width: 0, height: Double.leastNonzeroMagnitude))
}
var body: some View {
NavigationView{
Form{
Section{
Picker(selection: $selectedCurrency, label: Text("Date Format"), content: {
ForEach(0 ..< self.dateStyles.count) { (index:Int) in
Text("\(self.dateStyles[index])")
}
})
}
}.listStyle(PlainListStyle())
.listRowInsets(.init(top: 0, leading: 0, bottom: 0, trailing: 0))
.navigationBarTitle(Text("Settings"), displayMode: .inline)
.onAppear(){
if ProcessInfo.processInfo.environment["XCODE_RUNNING_FOR_PREVIEWS"] != "1"{
//some code
}
}
}
}
使用其他東西可能是最好的,但這會刪除填充。
Form {
...
}.padding(.leading, -16)
.padding(.trailing, -16)
你應該使用List
而不是Form
,看看不同的列表 styles ,我想你在.listStyle(GroupedListStyle())
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.