IOS动画
图片移动
- (IBAction)OpenAnimation:(id)sender {
[super viewDidAppear:YES];
[self.image setFrame:CGRectMake(0, 0, 100, 100)];
[UIView beginAnimations:@"xcodeImageViewAnimation" context:self.image];
[UIView setAnimationDuration:2];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(imageViewDidStop:finished:context:)];
[self.image setFrame:CGRectMake(100, 100, 100, 100)];
[UIView commitAnimations];
}
- (void)imageViewDidStop:(NSString *) paramAnimationID finished:(NSNumber *)paramFinished context:(void *)paramContext
{ NSLog(@"Animation finished.");
NSLog(@"Animation ID = %@", paramAnimationID);
UIImageView *contextImageView = (UIImageView *)paramContext;
NSLog(@"Image View = %@", contextImageView);
}图片由小变大
[super viewDidAppear:YES];
/* Place the image view at the center
of the view of this view controller */
self.image.center = self.view.center;
/* Make sure no translation is applied to this image view */ self.image.transform = CGAffineTransformIdentity;
/* Begin the animation */
[UIView beginAnimations:nil context:NULL];
/* Make the animation 5 seconds long */ [UIView setAnimationDuration:5.0f];
/* Make the image view twice as large in width and height */ self.image.transform = CGAffineTransformMakeScale(2.0f, 2.0f);
/* Commit the animation */
[UIView commitAnimations];图片的旋转
[super viewDidAppear:YES];
self.image.center = self.view.center;
/* Begin the animation */
[UIView beginAnimations:@"clockwiseAnimation" context:NULL];
/* Make the animation 5 seconds long */
[UIView setAnimationDuration:5.0f];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(imageViewDidStop:finished:context:)];
/* Rotate the image view 90 degrees */
self.image.transform =CGAffineTransformMakeRotation((90.0f * M_PI) / 180.0f);
/* Commit the animation */
[UIView commitAnimations];多动画次序
[UIView animateWithDuration:1.0
animations:^{
//self.label1.alpha = 0.0;
self.label2.alpha = 1.0;
self.label1.center = CGPointMake(100.0, 43);
}
completion:^(BOOL finished){}];

浙公网安备 33010602011771号