我正在尝试使用新的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'
答案 0 :(得分:0)
感谢this answer,看来问题出在我的快速语言版本(“目标”>“构建设置”>“快速语言版本”)。要使用此语法,必须为版本5。否则,我想我们需要将该属性视为字符串,并将其设置为kCAGradientLayerConic
。