Skip to content

Instantly share code, notes, and snippets.

@marybnq
Last active August 17, 2022 06:56
Show Gist options
  • Save marybnq/9a91190a631bc3a1926509d846bfa5fd to your computer and use it in GitHub Desktop.
Save marybnq/9a91190a631bc3a1926509d846bfa5fd to your computer and use it in GitHub Desktop.
Horizontal Scrollable Grid in SwiftUI - correct
var body: some View {
VStack{
ScrollView(.horizontal){
HStack {
ForEach(names, id: \.self) {name in
ZStack{
LinearGradient(colors: [.pink.opacity(0.5),.purple.opacity(0.7)], startPoint: .top, endPoint: .bottom)
.frame(width: 90, height: 90, alignment: .center)
.clipShape(RoundedRectangle(cornerRadius: 25))
Image(systemName: name)
.renderingMode(.original)
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 60, height: 60, alignment: .center)
}
}
} .fixedSize()
.padding()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment