|
|
5 năm trước cách đây | |
|---|---|---|
| .swiftpm | 5 năm trước cách đây | |
| ACarouselDemo | 5 năm trước cách đây | |
| Resource | 5 năm trước cách đây | |
| Sources | 5 năm trước cách đây | |
| .gitignore | 5 năm trước cách đây | |
| LICENSE | 5 năm trước cách đây | |
| Package.swift | 5 năm trước cách đây | |
| README.md | 5 năm trước cách đây | |
| README.zh-CN.md | 5 năm trước cách đây |
A carousel view for SwiftUI
English version | 中文文档
Open Xcode, go to File -> Swift Packages -> Add Package Dependency and enter https://github.com/JWAutumn/ACarousel
You can also add ACarousel as a dependency to your Package.swift:
dependencies: [
.package(url: "https://github.com/JWAutumn/ACarousel", from: "0.1.2")
]
Download and open the project, drag the ACarousel.swift file into your own project.
Basic use: The parameters of ACarousel have default values, so you can simply pass in the data source and eat it ~
struct Item: Identifiable, Equatable {
let id = UUID()
let image: Image
}
let roles = ["Luffy", "Zoro", "Sanji", "Nami", "Usopp", "Chopper", "Robin", "Franky", "Brook"]
struct ContentView: View {
let items: [Item] = roles.map { Item(image: Image($0)) }
var body: some View {
ACarousel(items) { item in
item.image
.resizable()
.scaledToFill()
.frame(height: 300)
.cornerRadius(30)
}
.frame(height: 300)
}
}
Customize configuration: You can configure the corresponding parameters to customize the display style according to your needs.
/// ...
struct ContentView: View {
let items: [Item] = roles.map { Item(image: Image($0)) }
var body: some View {
ACarousel(items,
spacing: 10,
headspace: 10,
sidesScaling: 0.7,
isWrap: true,
autoScroll: .active(2)) { item in
item.image
.resizable()
.scaledToFill()
.frame(height: 300)
.cornerRadius(30)
}
.frame(height: 300)
}
}
Download and open ACarouselDemo -> ACarouselDemo.xcodeproj, run and view.
Feel free to dive in! Open an issue or submit PRs.
MIT © JWAutumn