Carousel View는 여러 페이지 또는 아이템을 가로로 슬라이드하면서 보여주는 UI 컴포넌트다. 이런 형식인 듯 하다.
카드형식으로 되어 있어 좌우로 스크롤하는 형식이다.
Chat GPT에 물어봤더니 다음과 같은 코드를 반환했다.
import SwiftUI
struct ContentView: View {
var body: some View {
ScrollView(.horizontal, showsIndicators: false) {
HStack(spacing: 0) {
ForEach(0..<3) { index in
Text("Page \(index + 1)")
.frame(width: UIScreen.main.bounds.width, height: 200)
.background(Color.blue)
.foregroundColor(.white)
}
}
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
하지만 이 코드에는 자석처럼 고정되는 기능은 없던데, 이것도 캐러셀 뷰라 부르는지, 공부를 더 해야겠다.
'컴퓨터언어 > Swift' 카테고리의 다른 글
[Swift] Codable (0) | 2023.08.09 |
---|---|
[Swift] Optional (0) | 2023.08.09 |
[Swift] SwiftUI Tutorial(2)- Text View 커스터마이징하기. (0) | 2021.11.03 |
[Swift] SwiftUI Tutorial(1)- Xcode로 SwiftUI 프로젝트 만들기 (0) | 2021.11.03 |
[Swift] 다 큰 어른의 Swift Playground로 Swift 첫걸음 떼기 (0) | 2021.10.17 |