名为 IzziGradient 的轻量级软件包,旨在简化在 Swift 和 UIKit 中使用渐变。此工具旨在使创建和自定义渐变既直观又高效,为开发者提供一种简单的方式来增强其应用程序的视觉吸引力。
参数 |
类型 |
描述 |
默认值 |
gradientColors |
[UIColor] |
应用于渐变中的颜色数组。 |
[ ] |
colorLocations |
[NSNumber] |
渐变中每种颜色的位置。 |
[ ] |
startPoint |
CGPoint |
渐变的起始点。 |
x: 0.0, y: 0.0 |
endPoint |
CGPoint |
渐变的结束点。 |
x: 0.0, y: 1.0 |
newColors |
[UIColor] |
动画的目标颜色。 |
[ ] |
duration |
CFTimeInterval |
动画的持续时间。 |
3.0 |
repeatCount |
Float |
动画重复次数。 |
.infinity |
autoReverse |
Bool |
完成后反转方向。 |
true |
参数 |
类型 |
描述 |
默认值 |
gradientColors |
[UIColor] |
应用于渐变中的颜色数组。 |
[ ] |
centerPoint |
CGPoint |
渐变的起始点。 |
x: 0.5, y: 0.5 |
radius |
CGFloat |
渐变的结束点。 |
100.0 |
import izziGradient
let gradientView = IzziLinearGradient()
gradientView.gradientColors = [UIColor.white, UIColor.black]
gradientView.colorLocations = [0.5, 0.5]
gradientView.startPoint = CGPoint(x: 0.0, y: 0.0)
gradientView.endPoint = CGPoint(x: 0.4, y: 1.0)
gradientView.animateColors(to: [UIColor.green, UIColor.yellow], duration: 3.0, repeatCount: .infinity, autoReverse: true)
gradientView.animatePoints(to: CGPoint(x: 1.0, y: 0.0), endPoint: CGPoint(x: 0.0, y: 1.0), duration: 3.0, repeatCount: .infinity, autoReverse: true)
import izziGradient
let gradientView = IzziRadialGradient()
gradientView.gradientColors = [UIColor.white, UIColor.black]
gradientView.colorLocations = [0.0, 1.0]
gradientView.centerPoint = CGPoint(x: 0.5, y: 0.3)
gradientView.radius = 200

