// ViewController.m // 形变属性transform // // Created by LiuWei on 2018/4/23. // Copyright © 2018年 xxx. All rights reserved. // #import "ViewController.h" @interface ViewController () @property (weak, nonatomic) IBOutlet UIView *orangeV; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. } - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event { // CGAffineTransformMakeScale: 参数是x,y缩放比例系数 每次都是以最初位置的中心点为参考 就是说效果不会叠加 self.orangeV.transform = CGAffineTransformMakeScale(2, 3); // CGAffineTransformScale : 每次都是以传入的transform为参照(既 有叠加效果) self.orangeV.transform = CGAffineTransformScale(self.orangeV.transform, 4, 2); self.orangeV.transform = CGAffineTransformIdentity; //最初位置的中心点 一般可以作为CGAffineTransformScale的第一个参数 下面是效果 self.orangeV.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1, 2);//动一次 self.orangeV.transform = CGAffineTransformTranslate(self.orangeV.transform, 0, 50);//不停的动 } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end