func setupCircular(circularLayer:inout CAShapeLayer?){
if (circularLayer == nil) {
circularLayer = CAShapeLayer()
}else{
}
}
setupCircular(circularLayer: &nil)
怎么写?
答案 0 :(得分:2)
您不能在Swift中将值用作inout
参数。您需要创建一个CAShapeLayer
类型的变量,将其赋值nil
并将其用作函数的输入参数。
func setupCircular(circularLayer:inout CAShapeLayer?){
if (circularLayer == nil) {
circularLayer = CAShapeLayer()
}else{
}
}
var circ: CAShapeLayer? = nil
setupCircular(circularLayer: &circ)