-1
Ich bin neu in Xamarin iOS-Entwicklung, und ich habe versucht, das Symbol um 180 Grad zu drehen, wenn angezapft.
Ich schreibe die folgende Methode für die Rotation.Drehen Sie das Symbol um 180 Grad
private void titleViewTapped(UITapGestureRecognizer tap)
{
var rotationAnimation = new CoreAnimation.CABasicAnimation();
rotationAnimation.KeyPath = "transform.rotation.z";
rotationAnimation.To = new NSNumber(Math.PI);
rotationAnimation.Duration = 0.2;
rotationAnimation.RemovedOnCompletion = false;
rotationAnimation.FillMode = CoreAnimation.CAFillMode.Forwards;
triangleIcon.Layer.AddAnimation(rotationAnimation, "rotationAnimation");
}
Das Programm funktioniert gut, als ich den Titel zum ersten Mal angetippt habe.
Wenn ich jedoch erneut auf den Titel tippte, wurde das Symbol um 360 Grad gedreht, nicht um 180.
Wie löst man dieses Problem?
Ich habe dieses Problem selbst gelöst.
private void titleViewTapped(UITapGestureRecognizer tap)
{
UIView.Animate(0.2,
() => {
triangleIcon.Transform = CGAffineTransform.Rotate(triangleIcon.Transform, (nfloat)Math.PI);},
() => { }
);
}
Sie für den Kommentar danken. Der 'repeatCount' sollte nicht verwendet werden, da ich die Drehung nicht wiederholen möchte, nur wenn er angetippt wird –