Last active
August 17, 2022 06:56
-
-
Save marybnq/9a91190a631bc3a1926509d846bfa5fd to your computer and use it in GitHub Desktop.
Horizontal Scrollable Grid in SwiftUI - correct
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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