簡體   English   中英

CAShapeLayer動畫線lineCap屬性

[英]CAShapeLayer animate lineCap property

我想為CAShapeLayer的lineCap屬性設置動畫。 這是我的代碼:

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

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

什么都沒發生。 錯誤可能在keyPath中,但是找不到合適的值

看一下文檔:

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

搜索單詞“ animatable”。 您將找不到它(至少不是針對屬性)。 因此,您對可以為該屬性設置動畫的期望是錯誤的。

根據文檔,線帽不可設置動畫。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM