David Thank you for the direction, I am no longer using a timer for this Animation.
However the code below, when compiled w/ Xcode 3.2 does not display the dot layersŠbut, with Xcode 4 it works just fine? I have no idea why this is the case. Is it a bug? Not too complex: - (void) _createDotLayer { CGFloat radius = 2.0f; CGFloat startTime = 0.05f * _noOfDots; [self _removeDotLayers]; mDotLayers = [[NSMutableArray alloc] initWithCapacity:_noOfDots]; NSUInteger i, offset; for ( i=0; i < _noOfDots; i++ ) { CALayer* dotLayer = [CALayer layer]; // Array of Constraints offset += 10; NSArray* dotConstraints = [NSArray arrayWithObjects:[CAConstraint constraintWithAttribute:kCAConstraintMinX relativeTo:@"mmText" attribute:kCAConstraintMaxX scale:1.0f offset:offset], [CAConstraint constraintWithAttribute:kCAConstraintMinY relativeTo:@"mmText" attribute:kCAConstraintMinY scale:1.0f offset:3], nil]; // Dot Layer Properties dotLayer.backgroundColor = CGColorGetConstantColor(kCGColorWhite); dotLayer.cornerRadius = radius; dotLayer.frame = CGRectMake(0.0f,0.0f,radius*2,radius*2); dotLayer.constraints = dotConstraints; dotLayer.opacity = 0.0f; // Dot Layer Animation CABasicAnimation* forward = [CABasicAnimation animation]; [forward setFromValue:[NSNumber numberWithFloat:0.0f]]; [forward setToValue:[NSNumber numberWithFloat:1.0f]]; [forward setKeyPath:@"opacity"]; [forward setAutoreverses:NO]; [forward setFillMode:kCAFillModeForwards]; [forward setBeginTime:(i * startTime)]; CABasicAnimation* backward = [CABasicAnimation animation]; [backward setFromValue:[NSNumber numberWithFloat:1.0f]]; [backward setToValue:[NSNumber numberWithFloat:0.0f]]; [backward setKeyPath:@"opacity"]; [backward setAutoreverses:NO]; [backward setFillMode:kCAFillModeForwards]; [backward setBeginTime:((i * startTime) * 2)]; // Dot Layer Group Animation CAAnimationGroup* groupAnimation = [CAAnimationGroup animation]; [groupAnimation setAnimations:[NSArray arrayWithObjects:forward, backward, nil]]; [groupAnimation setDuration:_noOfDots]; [groupAnimation setRemovedOnCompletion:NO]; [groupAnimation setAutoreverses:NO]; [groupAnimation setRepeatCount:HUGE_VALF]; [groupAnimation setFillMode:kCAFillModeBoth]; [dotLayer addAnimation:groupAnimation forKey:@"dotAnimations"]; // Add Dot Layer to Loading Layer [self addSublayer:dotLayer]; [mDotLayers addObject:dotLayer]; // Garbage Collect forward = nil; backward = nil; groupAnimation = nil; dotConstraints = nil; } } Thanks, Arvin From: David Duncan <david.dun...@apple.com> Date: Tue, 19 Apr 2011 12:31:58 -0400 To: Arvin Bhatnagar <arvin.bhatna...@one.verizon.com> Cc: cocoa-dev <cocoa-dev@lists.apple.com> Subject: Re: CALayer: Animation using actions property On Apr 19, 2011, at 9:26 AM, Bhatnagar, Arvin wrote: Ok that worked if I were animating just one layer on its own. However, I am animating three separate layers in sequence to one another. I know we can group multiple animations for one layer (CAGroupAnimation). Other than using a timer, is there an alternative to coordinating the animation of different layers? All you should need to do is add the appropriate animations to each layer. If you need some kind of delay between them, you may find that putting them in a group animation gives you a nested context to do so. For example if you want an animation that progresses forward, pauses then reverses it may make more sense to have a group animation with 2 animations on a timeline with the included delays that repeats (but doesn't autoreverse, since your doing the reversal yourself). Depending on how you feel about it, it can either be a complex or fun game to see what you can do with animations to get an effect by itself ) -- David Duncan _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com