facebookarchive / pop

An extensible iOS and OS X animation library, useful for physics-based interactions.
Other
19.66k stars 2.88k forks source link

A bug about kPOPLayerRotationY. #361

Open HarwordLiu opened 7 years ago

HarwordLiu commented 7 years ago

Why the same code, X is normal, but when the rotation is Y and animation is finished, the view is crazy? Isn't this bug about kPOPLayerRotationY has not been fixed?

func configuraView() {

    aniView.backgroundColor = UIColor.green
    aniView.center = view.center
    view.addSubview(aniView)

    let tapGes = UITapGestureRecognizer(target: self, action: #selector(tap(_:)))
    aniView.addGestureRecognizer(tapGes)

}

func tap(_ sender: UITapGestureRecognizer) {
    aniView.layer.pop_removeAllAnimations()

    unowned let weakSelf = self

    let rotation = POPBasicAnimation(propertyNamed: kPOPLayerRotationY)
    rotation?.toValue = Double.pi / 2
    rotation?.completionBlock = ({(animation, finished) in
        let finishedAni = POPBasicAnimation(propertyNamed: kPOPLayerRotationY)

 //            finishedAni?.fromValue = Double.pi / 2
        finishedAni?.toValue = Double.pi
        finishedAni?.duration = 1

        weakSelf.aniView.backgroundColor = UIColor.blue
        weakSelf.aniView.layer.pop_add(finishedAni, forKey: "finished")
    })

    aniView.layer.pop_add(rotation, forKey: "rotation")

}