Oto przykład Xamarin iOS użyć do klapy narożnik przycisku kwadratowy, jak ucha psa (łatwo przenosić do obj-c):
![enter image description here](https://i.stack.imgur.com/udKDz.gif)
Metoda 1: użyciu animacji rotacji w 1
zarówno x
i y
osi (przykłady w Xamarin.iOS, ale łatwo przenośny obj-c):
AnimateNotify(0.10, 0, UIViewAnimationOptions.CurveEaseOut | UIViewAnimationOptions.AllowUserInteraction | UIViewAnimationOptions.BeginFromCurrentState,() =>
{
// note the final 3 params indicate "rotate around x&y axes, but not z"
var transf = CATransform3D.MakeRotation(-1 * (nfloat)Math.PI/4, 1, 1, 0);
transf.m34 = 1.0f/-500;
Layer.Transform = transf;
}, null);
Metoda 2: tylko dodać rotację x-axis
i y-axis
obrót do CAAnimationGroup
więc uruchomić w tym samym czasie:
AnimateNotify(1.0, 0, UIViewAnimationOptions.CurveEaseOut | UIViewAnimationOptions.AllowUserInteraction | UIViewAnimationOptions.BeginFromCurrentState,() =>
{
nfloat angleTo = -1 * (nfloat)Math.PI/4;
nfloat angleFrom = 0.0f ;
string animKey = "rotate";
// y-axis rotation
var anim = new CABasicAnimation();
anim.KeyPath = "transform.rotation.y";
anim.AutoReverses = false;
anim.Duration = 0.1f;
anim.From = new NSNumber(angleFrom);
anim.To = new NSNumber(angleTo);
// x-axis rotation
var animX = new CABasicAnimation();
animX.KeyPath = "transform.rotation.x";
animX.AutoReverses = false;
animX.Duration = 0.1f;
animX.From = new NSNumber(angleFrom);
animX.To = new NSNumber(angleTo);
// add both rotations to a group, to run simultaneously
var animGroup = new CAAnimationGroup();
animGroup.Duration = 0.1f;
animGroup.AutoReverses = false;
animGroup.Animations = new CAAnimation[] {anim, animX};
Layer.AddAnimation(animGroup, animKey);
// add perspective
var transf = CATransform3D.Identity;
transf.m34 = 1.0f/500;
Layer.Transform = transf;
}, null);