• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
CAKeyframeAnimation and NSView frame property
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CAKeyframeAnimation and NSView frame property


  • Subject: CAKeyframeAnimation and NSView frame property
  • From: "Mazen M. Abdel-Rahman" <email@hidden>
  • Date: Wed, 10 Mar 2010 13:35:19 -0700

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 (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

  • Follow-Ups:
    • Re: CAKeyframeAnimation and NSView frame property
      • From: David Duncan <email@hidden>
  • Prev by Date: Possible leak?
  • Next by Date: Re: Determining bounds of a glyph
  • Previous by thread: Re: Possible leak?
  • Next by thread: Re: CAKeyframeAnimation and NSView frame property
  • Index(es):
    • Date
    • Thread