Hi All,

I had another question about core animation.  I am trying to animate my view's 
frame size so that it gets smaller - and then in the same animation goes back 
to the same size.  I was able to get it to succesfully animate to a smaller 
size - but am having difficulty with getting to work using CAKeyFrameAnimation. 
 I tried doing it in a group - but when I try to change the alpha value nothing 
happens to the frame size.  I tried to follow some examples Apple had - but to 
no avail.  The view that I am calling this code on is layer backed (set in 
interface builder).

Thanks,
Mazen Abdel-Rahman

Below is my code:

        NSRect newFrame = [[subViewController view] frame];
        NSRect oldFrame = [[subViewController view] frame];

        newFrame.size.width = newFrame.size.width - 30;
                
        [NSAnimationContext beginGrouping];
        
        CAKeyframeAnimation * anim = [CAKeyframeAnimation animation];
        
        [anim setKeyPath:@"frame"];
        
        NSArray * frameValues = [NSArray arrayWithObjects:
                                                [NSValue 
valueWithRect:oldFrame],
                                                [NSValue 
valueWithRect:newFrame],
                                                [NSValue 
valueWithRect:oldFrame], nil];
        
        [anim setValues:frameValues];
        
        NSArray * times = [NSArray arrayWithObjects:
                                           [NSNumber numberWithFloat:0.0f],
                                           [NSNumber numberWithFloat:0.8f],
                                           [NSNumber numberWithFloat:1.0f],nil];
        
        [anim setKeyTimes:times];
        
        CABasicAnimation *alphaAnim = [CABasicAnimation 
animationWithKeyPath:@"alphaValue"];
        [alphaAnim setFromValue:[NSNumber numberWithFloat:0.0f]];
        [alphaAnim setToValue:[NSNumber numberWithFloat:1.0f]];
        
        CAAnimationGroup * group= [CAAnimationGroup animation];
        [group setAnimations:[NSArray arrayWithObjects:anim,alphaAnim,nil]];

        
        NSDictionary * dict = [NSDictionary dictionaryWithObject:group 
forKey:@"alphaValue"];
        
        [[subViewController view] setAnimations:dict];
        
        [[[subViewController view]animator] setAlphaValue:1.0];
                
        [NSAnimationContext endGrouping];

_______________________________________________

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

Reply via email to