Skip to content

Instantly share code, notes, and snippets.

@adrienbrault
Created June 8, 2011 23:12
Show Gist options
  • Save adrienbrault/1015686 to your computer and use it in GitHub Desktop.
Save adrienbrault/1015686 to your computer and use it in GitHub Desktop.
NSView *myView = ...;
myView.wantsLayer = YES; // The thing you must not forget.
CGPoint newPosition = CGPointMake(100.0, 200.0);
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"position"];
animation.fromValue = [NSValue valueWithPoint:myView.frame.origin];
animation.toValue = [NSValue valueWithPoint:newPosition];
animation.duration = 1.0;
[myView setFrameOrigin:newPosition];
[myView.layer addAnimation:animation forKey:@"position"];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment