SwiftUI HStack with Wrap

后端 未结 4 595
孤街浪徒
孤街浪徒 2020-11-29 07:08

Is it possible that the blue tags (which are currently truncated) are displayed completely and then it automatically makes a line break?

NavigationLink(desti         


        
4条回答
  •  情话喂你
    2020-11-29 07:37

    You need to handle line configurations right after Text View. Don't use lineLimit(1) if you need multiple lines.

     HStack(alignment: .top, spacing: 10){
                    ForEach(collection.platforms, id: \.self) { platform in
                        Text(platform)
                        .fixedSize(horizontal: false, vertical: true)
                        .lineLimit(10)
                        .multilineTextAlignment(.leading)
                            .padding(.all, 5)
                            .font(.caption)
                            .background(Color.blue)
                            .foregroundColor(Color.white)
                            .cornerRadius(5)
    
                    }
                }
    

提交回复
热议问题