SwiftUI ForEach & Swift ForEach All In One
SwiftUI ForEach & Swift ForEach All In One
Swift ForEach index
https://developer.apple.com/documentation/swift/array/1689783-foreach
SwiftUI ForEach index
https://developer.apple.com/documentation/swiftui/foreach
Swift ForEach & if statement
import SwiftUI
struct LeftView: View {
// var lefts: [LeftModel] = LeftData;
var lefts: [LeftModel];
var body: some View {
VStack(alignment: .leading, spacing: 4) {
ForEach(lefts) { item in
HStack {
Image(item.image)
.resizable()
.modifier(IconModifier());
Spacer();
Text(item.text);
}
// if (index !== lefts.length)
Divider();
}
}
}
}
✅
import SwiftUI
struct LeftView: View {
// var lefts: [LeftModel] = LeftData;
var lefts: [LeftModel];
var body: some View {
VStack(alignment: .leading, spacing: 4) {
ForEach(lefts) { item in
HStack {
Image(item.image)
.resizable()
.modifier(IconModifier());
Spacer();
Text(item.text);
}
if(item.text != "爆") {
Divider();
}
}
}
}
}
box overflow bug ???
refs
©xgqfrms 2012-2020
www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!
原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/16269899.html
未经授权禁止转载,违者必究!