图像旋转
#import "ViewController.h"
@interface ViewController ()
@property (strong, nonatomic) IBOutlet UIImageView *imageview;
- (IBAction)imageTransform:(UIButton *)sender;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)imageTransform:(UIButton *)sender {
//CGAffineTransform transform = self.imageview.transform;
if (sender.tag == 0)
{
//平移
//单次向上平移
//self.imageview.transform = CGAffineTransformMakeTranslation(0, -50);
//多次平移
self.imageview.transform = CGAffineTransformTranslate(self.imageview.transform, 0, -50);
}
if (sender.tag == 1)
{
//旋转
//单次旋转
//self.imageview.transform = CGAffineTransformMakeRotation(M_PI_4);//顺时针选装90°
//多次旋转
self.imageview.transform = CGAffineTransformRotate(self.imageview.transform, M_PI_4);
}
if (sender.tag == 2)
{
//缩放
//单次缩放
//self.imageview.transform = CGAffineTransformMakeScale(1.5, 1.5);
//多次缩放
self.imageview.transform = CGAffineTransformScale(self.imageview.transform, 1.5, 1.5);
}
}
@end