【发布时间】:2019-12-30 09:50:41
【问题描述】:
我似乎找不到在List 项目之间创建间距的方法。
也许我一开始就不应该列清单?
你怎么看?
这是生成视图的代码:
struct ContentView: View {
@ObservedObject var ratesVM = RatesViewModel()
init() {
UINavigationBar.appearance().largeTitleTextAttributes = [.foregroundColor: UIColor.white]
UITableView.appearance().backgroundColor = UIColor.init(named: "midnight blue")
UITableViewCell.appearance().backgroundColor = .green
UITableView.appearance().separatorStyle = .none
}
var body: some View {
NavigationView {
List (ratesVM.ratesList, id: \.self) { rate in
Image(systemName: "plus")
Button(action: {print("pressed")}) {
Text(rate.hebrewCurrencyName)
}
}
.navigationBarTitle("המרות מטבע")
.navigationBarItems(leading:
Button(action: {
print("button pressed")
self.ratesVM.callService()
}) {
Image(systemName: "plus")
.foregroundColor(Color.orange)})
}.environment(\.layoutDirection, .rightToLeft)
}
}
【问题讨论】:
-
@JawadAli 的答案似乎是从 Hacking with swift 执行此操作的正确方法。这是它包含视频解释的链接hackingwithswift.com/quick-start/swiftui/…
标签: ios swift listview swiftui