GradientView

@MainActor
open class GradientView : UIView

渐变View,无需设置渐变Layer的frame等,支持自动布局

  • 渐变Layer

    Declaration

    Swift

    @MainActor
    open var gradientLayer: CAGradientLayer { get }
  • 渐变色,CGColor数组

    Declaration

    Swift

    @MainActor
    open var colors: [Any]? { get set }
  • 渐变位置

    Declaration

    Swift

    @MainActor
    open var locations: [NSNumber]? { get set }
  • 渐变开始点

    Declaration

    Swift

    @MainActor
    open var startPoint: CGPoint { get set }
  • 渐变结束点

    Declaration

    Swift

    @MainActor
    open var endPoint: CGPoint { get set }
  • 初始化并指定渐变颜色、位置和渐变方向

    Declaration

    Swift

    @MainActor
    public convenience init(colors: [UIColor]?, locations: [NSNumber]?, startPoint: CGPoint, endPoint: CGPoint)
  • 指定layerClass为CAGradientLayer

    Declaration

    Swift

    @MainActor
    override open class var layerClass: AnyClass { get }
  • 设置渐变颜色、位置和渐变方向

    Declaration

    Swift

    @MainActor
    open func setColors(_ colors: [UIColor]?, locations: [NSNumber]?, startPoint: CGPoint, endPoint: CGPoint)