![]() |
![]() |
![]() |
Animated Gradient
使用 SwiftUI 编写的 Animated linear gradient 库
用法
最小示例
import AnimatedGradient
struct ContentView: View {
var body: some View {
AnimatedLinearGradient(colors: [.red, .green, .blue])
}
}
带修饰符
import AnimatedGradient
struct ContentView: View {
var body: some View {
AnimatedLinearGradient(colors: [.red, .green, .blue])
.numberOfSimultaneousColors(2)
.setAnimation(.linear(duration: 5))
.gradientPoints(start: .bottomLeading, end: .topTrailing)
}
}
必需参数 - 初始化
colors
- 颜色数组,渐变将在这其中的颜色之间切换
可用的自定义选项 - 修饰符
numberOfSimultaneousColors(Int)
- 在任何给定时间内屏幕上的颜色数量,可以多于、等于或少于数组中的颜色数量setAnimation(Animation)
- 一种颜色到另一种颜色过渡的动画gradientPoints(start:end:)
- 标准线性渐变控制点
预设
您可以使用GradientPreset的预选颜色快速开始
示例
尝试 AnimatedGradient 示例
- 克隆仓库
https://github.com/exyte/AnimatedGradient.git
- 打开
Example.xcodeproj
- 尝试一下吧!
安装
Swift 包管理器
dependencies: [
.package(url: "https://github.com/exyte/AnimatedGradient.git")
]
要求
- iOS 14.0+
我们其他的开源SwiftUI库
Grid - 最强大的网格容器
ScalingHeaderScrollView - 具有粘性头部并且滚动时缩小的滚动视图
AnimatedTabBar - 具有预置动画的标签栏
MediaPicker - 可定制的媒体选择器
Chat - 具有完全可定制消息单元格、输入视图和内置媒体选择器的聊天UI框架
ConcentricOnboarding - 动画引导流程
FloatingButton - 悬浮按钮菜单
ActivityIndicatorView - 许多动态加载指示器
ProgressIndicatorView - 许多动态进度指示器
SVGView - SVG解析器
LiquidSwipe - 液态导航动画
PopupView - 使用SwiftUI编写的Toast、警报和弹出库