2011-06-01 3 views
0

Je suis un débutant et je continue à essayer de me familiariser avec CALayer ...CALayer Animations

Merci encore @Alexsander Akers, @DHamrick et @Tommy parce que maintenant je peux biaiser mon CALayer!

Il ressemble à:

capt 1

Je voudrais passer mon doigt sur le gris UIView (avec touchesBegan/touchesMoved/touchesEnded) et mes "cartes" déplacer comme ceci: (Pour exemple si Je déplace mon doigt vers la gauche)

  • carton jaune disparaître & une prise verte est un lieu
  • blanc prendre la place verte
  • rouge le blanc
  • bleu rouge un
  • et au lieu d'une carte bleue d'un noir apparaît ...

Peut-être que je rêve et il est à dur pour moi, mais si vous pouvez me donner des conseils, je vais le prendre !!

merci!

Répondre

0

Vous pouvez utiliser la fonction personnalisée comme celui-ci

- (void)moveAndRotateLayer: (CALayer *)layer withDuration:(double)duration degreeX:(double)degreeX y:(int)degreeY angle:(float)angle autoreverseEnable:(BOOL)ar repeatTime:(int)repeat andTimingFunctionType:(NSString *)type 
{ 
    // You should type the timing function type as "Liner", "EaseIn", "EaseOut" or "EaseInOut". 
    // The default option is the liner timing function. 
    // About these functions, look in the Apple's reference documents. 

    CAAnimationGroup *theGroup = [CAAnimationGroup animation]; 

    CGPoint movement = CGPointMake(layer.position.x + degreeX, layer.position.y + degreeY); 
    NSArray *animations = [NSArray arrayWithObjects:[self moveLayers:layer to:movement duration:duration], [self rotateLayers:layer to:angle duration:duration], nil]; 

    theGroup.duration = duration; 
    theGroup.repeatCount = repeat; 
    theGroup.autoreverses = ar; 

    if ([type isEqualToString:@"EaseIn"]) 
    { 
     theGroup.timingFunction = [CAMediaTimingFunction functionWithName: kCAMediaTimingFunctionEaseIn]; 
    } 
    else if ([type isEqualToString:@"EaseOut"]) 
    { 
     theGroup.timingFunction = [CAMediaTimingFunction functionWithName: kCAMediaTimingFunctionEaseOut]; 
    } 
    else if ([type isEqualToString:@"EaseInOut"]) 
    { 
     theGroup.timingFunction = [CAMediaTimingFunction functionWithName: kCAMediaTimingFunctionEaseInEaseOut]; 
    } 
    else 
    { 
     theGroup.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]; 
    } 

    theGroup.animations = [NSArray arrayWithArray:animations]; 

    [layer addAnimation:theGroup forKey:@"movingAndRotating"]; 
} 

Ceci est la solution de l'animation juste pour le déplacement et la rotation de la couche,

mais je sais que vous pouvez vous personnaliser.

C'est très bon pour vous. Tu peux le faire.

Bonne chance!