标签:
1 // 平移 2 - (IBAction)trasnlate:(id)sender { 3 // 一次性的移动10 的距离 4 // _button.transform = CGAffineTransformMakeTranslation(10, 0); 5 6 // 如果想要持续移动,那么就需要得到当前view的transform 7 // 1. 获取当前button的transform属性 8 CGAffineTransform transform = _button.transform; 9 10 // 2. 在transform的基础上进行修改 11 _button.transform = CGAffineTransformTranslate(transform, 10, 0); 12 } 13 14 // 缩放 15 - (IBAction)scal:(id)sender { 16 // 执行缩放 17 // _button.transform = CGAffineTransformMakeScale(0.5, 0.5); 18 19 // 持续执行缩放 20 // 1. 获取当前button的transform 21 CGAffineTransform transform = _button.transform; 22 23 // 2. 在transform进行修改 24 _button.transform = CGAffineTransformScale(transform, 0.5, 0.5); 25 } 26 27 // 旋转 28 - (IBAction)rotate:(id)sender { 29 30 // _button.transform = CGAffineTransformMakeRotation(M_PI_4); 31 32 33 34 [UIView animateWithDuration:1 animations:^{ 35 // 1. 获取当前button的transform 36 CGAffineTransform transform = self.button.transform; 37 38 // 2. 在transform进行修改 39 self.button.transform = CGAffineTransformRotate(transform, M_PI_4); 40 41 self.button.transform = CGAffineTransformTranslate(transform, 30, 0); 42 43 self.button.transform = CGAffineTransformScale(transform, 1.5, 1.5); 44 }]; 45 } 46 47 - (IBAction)reset:(id)sender { 48 // 恢复原始状态 49 _button.transform = CGAffineTransformIdentity; 50 }
标签:
原文地址:http://www.cnblogs.com/DoNib-Coding/p/4780702.html