创建一个singleView工程,名为animDemo
在xib中放三个按钮,和一个imgview控件。
为三个按钮关联三个方法。
- (IBAction)pressRight:(UIButton *)sender;
- (IBAction)pressHide:(UIButton *)sender;
- (IBAction)pressRotate:(UIButton *)sender;
- (IBAction)pressRight:(UIButton *)sender {
[UIViewbeginAnimations:@"moveRight"context:nil];
sender.center=CGPointMake(250.,60.);
[UIViewcommitAnimations];
}
- (IBAction)pressHide:(UIButton *)sender {
[UIViewbeginAnimations:@"hide"context:nil];
[UIViewsetAnimationDuration:2];
sender.alpha=0;
[UIViewcommitAnimations];
}
- (IBAction)pressRotate:(UIButton *)sender {
[UIViewbeginAnimations:@"rotate"context:nil];
//[UIView setAnimationRepeatCount:2.];
//sender.transform=CGAffineTransformMakeRotation(M_PI_2);
sender.transform=CGAffineTransformRotate(sender.transform,M_PI_2);
//sender.transform=CGAffineTransformScale(sender.transform, 1.5, 1.5); //放大
[UIViewcommitAnimations];
}
导入类animation类- (IBAction)pressRotate:(UIButton *)sender {
[UIViewbeginAnimations:@"rotate"context:nil];
//[UIView setAnimationRepeatCount:2.];
//sender.transform=CGAffineTransformMakeRotation(M_PI_2);
sender.transform=CGAffineTransformRotate(sender.transform,M_PI_2);
//sender.transform=CGAffineTransformScale(sender.transform, 1.5, 1.5); //放大
[UIViewcommitAnimations];
_imageView.image=[UIImageimageNamed:@"2.jpg"];
[AnimationshowAnimationType:@"cube"withSubType:kCATransitionFromBottomView:_imageView];
}