CABasicAnimation in Swift Playground

前端 未结 1 1946
小蘑菇
小蘑菇 2021-01-12 10:19

Been going nuts trying to get a live view of an animation in a Swift Playground like in the WWDC \"Swift Playgrounds\" video. I tried to do a UIView.animateWithDuratio

相关标签:
1条回答
  • 2021-01-12 10:35

    The first part of the solution is to enable the Run in Full Simulator option. See this answer for a step-by-step.

    The second part of the solution is to contain your animated view in a container view, e.g.:

    let container = UIView(frame: CGRect(x: 0, y: 0, width: 400, height: 400))
    XCPShowView("Circle Animation", container)
    let test = timerButtonGraphics(frame: CGRect(x: 198, y: 0, width: 4, height: 400))
    container.addSubview(test)
    

    The third part of the solution is to correct your animation. The keyPath should be transform.scale.x instead of scale.x and you need to add a duration, e.g.:

    anim.keyPath = "transform.scale.x"
    anim.duration = 5
    

    You should then be able to view the animation in your playground.

    0 讨论(0)
提交回复
热议问题