Created
November 4, 2015 15:27
-
-
Save MaximAlien/e91d5b15de8f3d73055c to your computer and use it in GitHub Desktop.
[iOS] [CAAnimation] Simple animation of the view
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 50, 50, 50)]; | |
[view setBackgroundColor:[UIColor blackColor]]; | |
[self.view addSubview:view]; | |
CABasicAnimation *animation = [CABasicAnimation animation]; | |
animation.keyPath = @"position.x"; | |
animation.fromValue = @0; | |
animation.toValue = @(self.view.frame.size.width); | |
animation.duration = 1; | |
animation.fillMode = kCAFillModeForwards; | |
animation.removedOnCompletion = YES; | |
[view.layer addAnimation:animation forKey:@"basic"]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment