J'ai besoin d'un exemple de code où je peux animer un tracé courbe/arc qui devrait dessiner un cercle entier comme animé?CGPath Animation
Toute contribution sera appréciée.
Merci, Sat
J'ai besoin d'un exemple de code où je peux animer un tracé courbe/arc qui devrait dessiner un cercle entier comme animé?CGPath Animation
Toute contribution sera appréciée.
Merci, Sat
MISE À JOUR: Se rendant compte qu'il ya une meilleure solution à ce problème. Créez simplement un chemin circulaire et animez la propriété strokeEnd d'un CAShapeLayer de 0.0f à 1.0f. Jetez un oeil à cette réponse de Ole: Drawing a path with CAKeyFrameAnimation on iPhone
ORIGINAL RÉPONSE:
Vous pouvez utiliser un CAKeyframeAnimation et créer un chemin Core Graphics. Ce code anime une couche dans un motif parabolique, mais vous pouvez l'adapter pour dessiner un cercle.
- (CAAnimation*)pathAnimation;
{
CGMutablePathRef path = CGPathCreateMutable();
CGPathMoveToPoint(path,NULL,50.0,120.0);
CGPathAddCurveToPoint(path,NULL,50.0,275.0,
150.0,275.0,
150.0,120.0);
CGPathAddCurveToPoint(path,NULL,150.0,275.0,
250.0,275.0,
250.0,120.0);
CGPathAddCurveToPoint(path,NULL,250.0,275.0,
350.0,275.0,
350.0,120.0);
CGPathAddCurveToPoint(path,NULL,350.0,275.0,
450.0,275.0,
450.0,120.0);
CAKeyframeAnimation *
animation = [CAKeyframeAnimation
animationWithKeyPath:@"position"];
[animation setPath:path];
[animation setDuration:3.0];
[animation setAutoreverses:YES];
CFRelease(path);
return animation;
}
Que voulez-vous dire "dessiner un cercle complet comme animé?" Comment voulez-vous animer dessiner votre cercle? Voulez-vous commencer à dessiner un coin minuscule, comme une petite fraction d'un graphique à secteurs, et que le coin devient de plus en plus grand jusqu'à ce qu'il soit de la taille du cercle complet? –