Re: CoreAnimation - Resizing sublayers along with superlayer animation
Re: CoreAnimation - Resizing sublayers along with superlayer animation
- Subject: Re: CoreAnimation - Resizing sublayers along with superlayer animation
- From: Ahsan Shafiq <email@hidden>
- Date: Sat, 21 Aug 2010 05:46:56 -0430
Hi
You can use scale, but if you also want to detect touches on these layers
you have to update the model as well which is nearly impossible to do if you
are doing scalling.
But apart from this scaling will work just fine.
On Fri, Aug 20, 2010 at 3:54 AM, Ignacio Enriquez <email@hidden> wrote:
> Hi,
>
> I have a subclass of CALayer (below self) and it has a sublayer
> (textLayer).
> I want self to be shrank and enlarges, so I created animations like
> the following:
>
> CABasicAnimation *fadeInAnimation;
> fadeInAnimation=[CABasicAnimation animationWithKeyPath:@"opacity"];
> fadeInAnimation.repeatCount = 1;
> fadeInAnimation.autoreverses = NO;
> fadeInAnimation.fromValue = [NSNumber numberWithFloat:1.0];
> fadeInAnimation.toValue = [NSNumber numberWithFloat:0.0];
>
> CABasicAnimation *shrinkAnimation;
> shrinkAnimation = [CABasicAnimation animationWithKeyPath:@"bounds.size"];
> shrinkAnimation.repeatCount = 1;
> shrinkAnimation.autoreverses = NO;
> shrinkAnimation.timingFunction = [CAMediaTimingFunction
> functionWithName:kCAMediaTimingFunctionEaseIn];
> shrinkAnimation.toValue = [NSValue valueWithCGSize:CGSizeMake(0, 0)];
>
> aniGroupOFF = [[CAAnimationGroup animation] retain];
> aniGroupOFF.delegate = self;
> aniGroupOFF.duration = ANI_DURATION;
> aniGroupOFF.animations = [NSArray arrayWithObjects:shrinkAnimation,
> fadeInAnimation, nil];
>
> then I commit the animation
>
> [self addAnimation:aniGroupOFF forKey:@"shrinkAndFadeOff"];
>
> self is animated as expected but sublayer textLayer is not resized, it
> just changes its position according to the new bounds of self
>
> I would like to have the same effect when animation view, they resize
> automatically their subviews and/or sublayers
>
> Thanks in advance.
>
> BTW: I tried also:
> [self setNeedsDisplayOnBoundsChange:YES];
> and overriding
> -(void)layoutSublayers{[textLayer setFrame:accordingFrame];}
> but didn't work ;(
>
>
> Ignacio
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> 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:
>
>
> This email sent to email@hidden
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden