项目
在 GitHub 查看
JWAutumn/ACarousel
关于
SwiftUI 的轮播视图 | SwiftUI 旋转木马效果
网站与应用开发实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- -1
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.zh-CN.md
原文ACarousel
SwiftUI 旋转木马效果
内容列表
要求
- iOS 13.0+ / macOS 10.15+ / tvOS 13.0+
- Xcode 11.0+
- Swift 5.1+
安装
Swift Package Manager
打开 Xcode, 选择 File -> Swift Packages -> Add Package Dependency,输入 https://github.com/JWAutumn/ACarousel
也可以将 ACarousel 作为依赖添加项到你的 Package.swift 中:
dependencies: [
.package(url: "https://github.com/JWAutumn/ACarousel", from: "0.2.0")
]
手动安装
下载并打开项目,把 ACarousel.swift 文件拖入到你自己的项目当中。
当然,你也可以根据特定需求修改代码。
使用说明
- 基础使用:
ACarousel的参数有默认值,你只需要简单的传入数据源即可食用~
struct Item: Identifiable {
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)
}
}
或者:
...
var body: some View {
ACarousel(roles, id: \.self) { name in
Image(name)
.resizable()
.scaledToFill()
.frame(height: 300)
.cornerRadius(30)
}
.frame(height: 300)
}
...
- 自定义参数:根据自身需求,你可以修改相应的参数来自定义显示样式。
/// ...
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)
}
}
示例
下载项目,打开 ACarouselDemo -> ACarouselDemo.xcodeproj 运行并查看
维护者
@JWAutumn,@Underthestars-zhy, @Alexander Chapliuk,@thitran-incepit。
如何贡献
非常欢迎你的加入!提一个 Issue 或者提交一个 Pull Request。
使用许可
MIT © JWAutumn
探索相关项目
加载中…