ios开发transform属性

 "ViewController.h"

@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIImageView *imageV;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (IBAction)moveUp:(id)sender {
    //平移
    [UIView animateWithDuration:0.5 animations:^{
        //使用Make,它是相对于*原始的位置做的形变.不累加形变,且多次点击只形变一次
        //self.imageV.transform = CGAffineTransformMakeTranslation(0, -100);
        //相对于上一次做形变.初始值self.imageV.transform为0,多次点击,会自动在上一次形变的基础上做平移
        self.imageV.transform = CGAffineTransformTranslate(self.imageV.transform, 0, -100);
    }];
    
}
- (IBAction)moveDown:(id)sender {
    
    //平移
    [UIView animateWithDuration:0.5 animations:^{
        //使用Make,它是相对于*原始的位置做的形变.
        //self.imageV.transform = CGAffineTransformMakeTranslation(0, -100);
        //相对于上一次做形变.
        self.imageV.transform = CGAffineTransformTranslate(self.imageV.transform, 0, 100);
    }];
}

- (IBAction)rotation:(id)sender {
    
    [UIView animateWithDuration:0.5 animations:^{
        
        //旋转(旋转的度数, 是一个弧度),M_PI_4,_下划线表示一个除号/
        //self.imageV.transform = CGAffineTransformMakeRotation(M_PI_4);
        
        self.imageV.transform = CGAffineTransformRotate(self.imageV.transform, M_PI_4);
        
    }];
    
}
- (IBAction)scale:(id)sender {
    
    
    [UIView animateWithDuration:0.5 animations:^{
        
       //缩放
        //self.imageV.transform = CGAffineTransformMakeScale(0.5, 0.5);
        self.imageV.transform = CGAffineTransformScale(self.imageV.transform, 0.8, 0.8);
        
       
    }];
    
    
}

/**
 *    总结:
 
 1:平移:transform是结构体,定义一个transform:CGAffineTransform form
 
 //使用Make,它是相对于*原始的位置做的形变.不累加形变,且多次点击只形变一次
 //self.imageV.transform = CGAffineTransformMakeTranslation(0, -100);
 //相对于上一次做形变.初始值self.imageV.transform为0,多次点击,会自动在上一次形变的基础上做平移
 self.imageV.transform = CGAffineTransformTranslate(self.imageV.transform, 0, -100);
 
 
 2:旋转:
 //旋转(旋转的度数, 是一个弧度),M_PI_4,_下划线表示一个除号/
 //self.imageV.transform = CGAffineTransformMakeRotation(M_PI_4);
 
 self.imageV.transform = CGAffineTransformRotate(self.imageV.transform, M_PI_4);
 
 
 3:缩放:
 //缩放
 //self.imageV.transform = CGAffineTransformMakeScale(0.5, 0.5);
 self.imageV.transform = CGAffineTransformScale(self.imageV.transform, 0.8, 0.8);
 
 
 4:清空形变属性:
   CGAffineTransform form = CGAffineTransformIdentity;
   self.imageV.transform = form;
 
 
 5:1:在实际开发中,使用场景:1:当涉及一些frame的改变或是形变的时候可以用transform来取代frame 2:一般在实际开发中都是平移,旋转缩放混合使用。
 
 */

@end