类型 'CAGradientLayerType'(又名 'NSString')没有成员 'conic'
Type 'CAGradientLayerType' (aka 'NSString') has no member 'conic'
我正在尝试使用新的 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'
感谢 看来问题是我的 swift 语言版本(目标 > 构建设置 > Swift 语言版本)。它需要是版本 5 才能使用此语法。否则,我想我们需要将 属性 视为字符串,并将其设置为 kCAGradientLayerConic
.
我正在尝试使用新的 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'
感谢 kCAGradientLayerConic
.