简体   繁体   中英

CAShapeLayer animate lineCap property

I would like to animate lineCap property of a CAShapeLayer. Here is my code:

  func animate() {
    let animation = CABasicAnimation(keyPath: "lineCap")
    animation.toValue = CAShapeLayerLineCap.round
    animation.duration = 0.3

    //var progressLayer: CAShapeLayer?
    progressLayer?.add(animation, forKey: "AnimationKey")
  }

Nothing happens. Probably the error is in keyPath, but a can't find proper value

Take a look at the documentation:

https://developer.apple.com/documentation/quartzcore/cashapelayer/1521905-linecap

Search for the word "animatable". You won't find it (at least, not with respect to this property). So your expectation that you can animate this property is wrong.

Line cap is not animatable according to the documentation.

https://developer.apple.com/documentation/quartzcore/cashapelayer

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM