【问题标题】:Type 'CAGradientLayerType' (aka 'NSString') has no member 'conic'类型“CAGradientLayerType”(又名“NSString”)没有成员“圆锥”
【发布时间】:2020-01-17 07:10:26
【问题描述】:

我正在尝试使用新的conic gradient type。我已经将部署目标设置为 12.0 并添加了 QuartzCore 框架,并且我将渐变的类型设置为 .conic:

    let gradient = CAGradientLayer()
    gradient.type = CAGradientLayerType.conic

我什至可以点击进入文档:

extension CAGradientLayerType {
    ...

    /* Conic gradient. The gradient is centered at 'startPoint' and its 0-degrees
     * direction is defined by a vector spanned between 'startPoint' and
     * 'endPoint'. When 'startPoint' and 'endPoint' overlap the results are
     * undefined. The gradient's angle increases in the direction of rotation of
     * positive x-axis towards positive y-axis. */

    @available(iOS 12.0, *)
    public static let conic: CAGradientLayerType
}

但我仍然收到此构建错误:

Type 'CAGradientLayerType' (aka 'NSString') has no member 'conic'

【问题讨论】:

    标签: gradient cagradientlayer


    【解决方案1】:

    感谢this answer,看来问题出在我的 Swift 语言版本上(目标 > 构建设置 > Swift 语言版本)。必须是版本 5 才能使用此语法。否则,我想我们需要将该属性视为字符串,并将其设置为kCAGradientLayerConic

    【讨论】:

      猜你喜欢
      • 2019-04-02
      • 1970-01-01
      • 1970-01-01
      • 2018-03-13
      • 1970-01-01
      • 1970-01-01
      • 2020-08-11
      • 2019-07-08
      • 1970-01-01
      相关资源
      最近更新 更多