2017
CA .
" Alex"...
...
@IBDesignable
class SpinningThing: UIView {
public func runAnimation() {
speedy = 1.0
startFastThenSlowDown()
}
override func layoutSubviews() {
super.layoutSubviews()
setup()
}
func setup() {
setup .. other stuff (draw things)
setupThingThatSpins()
}
var thingThatSpins = CAShapeLayer()
var speedy = 0.5
var finalSpeed = 13.0
func setupThingThatSpins() {
let p = UIBezierPath( .. etc etc
thingThatSpins.strokeColor .. etc etc
}
startFastThenSlowDown...
func startFastThenSlowDown() {
speedy *= 1.175
animeSpinRestartable(spr: speedy)
if speedy < finalSpeed {
delay(0.1) { self._slowDown() }
}
}
, Alex...
func animeSpinRestartable(spr: CFTimeInterval) {
let _key = "animeSpinRestartable"
thingThatSpins.removeAnimation(forKey: _key)
let t3 = arcs.presentation()?.transform
let cur = (t3 == nil) ? 0 : atan2(t3!.m12, t3!.m11)
let r = _typicalAnim(keyPath: "transform.rotation.z")
r.fromValue = cur
r.toValue = cur + 2 * CGFloat.pi
r.duration = spr
thingThatSpins.add(r, forKey: _key)
}
thingThatSpins ( ), - ( , !)
, OP.