[SwiftUI] ScrollView
使用ScrollView將需要滾動的程式碼包起來(預設為垂直滾動)
客製化CardView請參考
ScrollView{
VStack{
CardView(image: "swiftui-button", category: "SwiftUI", heading: "Drawing a Border with Rounded Corners", author: "Simon Ng")
CardView(image: "natural-language-api", category: "macOS", heading: "Drawing a Border with Rounded Corners", author: "Simon Ng")
CardView(image: "macos-programming", category: "SwiftUI", heading: "Drawing a Border with Rounded Corners", author: "Simon Ng")
CardView(image: "flutter-app", category: "SwiftUI", heading: "Drawing a Border with Rounded Corners", author: "Simon Ng")
}
}
如果需要左右水平滾動的話在ScrollView加上.horizontal
ScrollView(.horizontal){
HStack{
CardView(image: "swiftui-button", category: "SwiftUI", heading: "Drawing a Border with Rounded Corners", author: "Simon Ng").frame(width: 300)
CardView(image: "natural-language-api", category: "macOS", heading: "Drawing a Border with Rounded Corners", author: "Simon Ng").frame(width: 300)
CardView(image: "macos-programming", category: "SwiftUI", heading: "Drawing a Border with Rounded Corners", author: "Simon Ng").frame(width: 300)
CardView(image: "flutter-app", category: "SwiftUI", heading: "Drawing a Border with Rounded Corners", author: "Simon Ng").frame(width: 300)
}
}
Spacer()
}