仿射变换-CGAffineTransform

 

  • 平移(Translation)
  • 缩放(Scale)
  • 翻转(Flip)
  • 旋转(Rotation)
  • 剪切(Shear)
 //位移仿射
  CGAffineTransformMakeTranslation
  CGAffineTransformTranslate
  //旋转仿射
  CGAffineTransformMakeRotation
  CGAffineTransformRotate
  //缩放仿射
  CGAffineTransformMakeScale
  CGAffineTransformScale

  //叠加仿射效果
  CGAffineTransformConcat

 

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{

    [UIView animateWithDuration:.25 animations:^{
        
        // 平移
//        _imgView.transform = CGAffineTransformTranslate(_imgView.transform, 10, 10);
//        // 缩放
//        _imgView.transform = CGAffineTransformScale(_imgView.transform, 1.1, 1.1);
//        //旋转
//        _imgView.transform = CGAffineTransformRotate(_imgView.transform, M_PI_2);
        
//        _imgView.transform = CGAffineTransformMakeScale(1.1,1.1);
//        _imgView.transform = CGAffineTransformMakeRotation(M_PI_2);
//        _imgView.transform = CGAffineTransformMakeTranslation(120, 120);
        
//        _imgView.transform = CGAffineTransformMake(1,0.5,0.5,1,0,0);

    }];
}
它的作用是清除之前对矩阵设置的仿射效果,或者用来初始化一个原始无效果的仿射矩阵

   _imgView.transform = CGAffineTransformIdentity;

//检查是否有做过仿射效果
CGAffineTransformIsIdentity(transform)

//检查2个仿射效果是否相同
CGAffineTransformEqualToTransform(transform1,transform2)

//仿射效果反转(反效果,比如原来扩大,就变成缩小) CGAffineTransformInvert(transform)
 
     //位移仿射
        CGAffineTransformMakeTranslation
        CGAffineTransformTranslate
        //旋转仿射
        CGAffineTransformMakeRotation
        CGAffineTransformRotate
        //缩放仿射
        CGAffineTransformMakeScale
        CGAffineTransformScale

        //叠加仿射效果
        CGAffineTransformConcat
 

总结一下CATransform3DMakeRotation方法的6个参数

在不考虑旋转时,CATransform3DMakeRotation6个参数可以写成

//sx,sy:缩放因子
//shx,shy:斜切因子
//tx,ty:移动因子
CGAffineTransformMake (sx,shx,shy,sy,tx,ty)

 

posted @ 2016-03-22 15:04  人生路1/5  阅读(302)  评论(0编辑  收藏  举报