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, 禁止转载
标签:lefts,LeftModel,item,ForEach,var,Swift 来源: https://www.cnblogs.com/xgqfrms/p/16269899.html