一个 SwiftUI 框架,用于使用缓动函数创建平滑渐变。
线性渐变往往会产生硬边,这在对比强烈的颜色之间过渡时更为明显。 此框架提供了一种使用缓动函数创建更平滑渐变的简单方法。
线性 | 平滑 |
---|---|
![]() |
![]() |
将以下内容添加到您的 Package.swift
文件
.package(url: "https://github.com/raymondjavaxx/SmoothGradient.git", from: "1.0.0")
要从 Xcode 添加,请转到 File -> Add Package Dependencies... 并输入上面的 URL。
将以下内容添加到您的 Podfile
pod 'SmoothGradient', '~> 1.0.0'
import SmoothGradient
struct ContentView: View {
var body: some View {
LinearGradient(
gradient: .smooth(from: .black, to: .white, curve: .easeInOut), // ⬅️
startPoint: .top,
endPoint: .bottom
)
}
}
import SmoothGradient
struct ContentView: View {
var body: some View {
SmoothLinearGradient( // ⬅️
from: .black,
to: .white,
startPoint: .top,
endPoint: .bottom,
curve: .easeInOut
)
}
}
SmoothGradient 基于 MIT 许可证发布。 有关更多信息,请参阅 LICENSE 文件。