[英]How to remove right left padding of `Form` in SwiftUI?
How to remove the left and right Padding of a Form in SwiftUI?如何去除SwiftUI中Form的左右填充? Every View I create has padding in the leading and trailing.
我创建的每个视图在前导和尾随都有填充。
Here is my code这是我的代码
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
}
}
}
}
Using something else is probably best but this removes the padding.使用其他东西可能是最好的,但这会删除填充。
Form {
...
}.padding(.leading, -16)
.padding(.trailing, -16)
You should use a List
instead of a Form
, take a look at the different list styles , I think you are after .listStyle(GroupedListStyle())
你应该使用
List
而不是Form
,看看不同的列表 styles ,我想你在.listStyle(GroupedListStyle())
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.