transform:形变属性,能完成的功能:平移、缩放、旋转
- 平移
self.tempView.transform = CGAffineTransformMakeTranslation(-100, 100);
缩放
self.tempView.transform = CGAffineTransformMakeScale(0.5, 0.5);
- 旋转
self.tempView.transform = CGAffineTransformMakeRotation(-M_PI_4);
- 几种形变叠加处理
例一:
CGAffineTransform translation = CGAffineTransformMakeTranslation(-100, 100);//平移
CGAffineTransform scaleTranslation = CGAffineTransformScale(translation, 0.5, 0.5);//缩放
CGAffineTransform rotateScaleTranslation = CGAffineTransformRotate(scaleTranslation, M_PI_2); //旋转
self.tempView.transform = rotateScaleTranslation;
例二:每次旋转M_PI_4
[UIView animateWithDuration:1.0 animations:^{self.tempView.transform = CGAffineTransformRotate(self.tempView.transform, M_PI_4);
}];
- 清空transform的形变(以前的平移、缩放、旋转都会消失)
[UIView animateWithDuration:2.0 animations:^{
self.tempView.transform =CGAffineTransformIdentity;}];