WCLLoadingView
WCLLoadingView copied to clipboard
方便解释一下这段代码吗?
//三角形两边的比例
let scale = (lineLength - 2*margin)/(lineLength - lineWidth)
for i in 0...3 {
var keypath = "transform.translation.y"
if i%2 == 1 {
keypath = "transform.translation.x"
}
let lineAnimationTwo = CABasicAnimation.init(keyPath: keypath)
lineAnimationTwo.beginTime = CACurrentMediaTime() + duration/2
lineAnimationTwo.duration = duration/4
lineAnimationTwo.fillMode = kCAFillModeForwards
lineAnimationTwo.isRemovedOnCompletion = false
lineAnimationTwo.autoreverses = true
lineAnimationTwo.fromValue = 0
if i == 0 || i == 3 {
lineAnimationTwo.toValue = lineLength/4 * scale
}else {
lineAnimationTwo.toValue = -lineLength/4 * scale
}
let lineLayer = lines[i]
lineLayer.add(lineAnimationTwo, forKey: "lineAnimationThree")
}
这段代码中 三角形两边比例指的是哪个三角形,没看太懂,能简单解释一下这个 scale的含义吗?
还有这个 lineLength/4
是从那里来的?
lineAnimationTwo.toValue = lineLength/4 * scale