xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

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, 禁止转载 🈲️,侵权必究⚠️!


posted @ 2022-05-14 13:49  xgqfrms  阅读(72)  评论(2编辑  收藏  举报