transfrom属性

来源:互联网 发布:sql的delete 编辑:程序博客网 时间:2024/06/05 20:18
transfrom可以实现一些形变。常见的有平移、缩放和旋转三种。使用起来很简单:
//横纵放大1.3倍                self.imageButton.transform=CGAffineTransformScale(self.imageButton.transform, 1.3, 1.3);
//逆时针旋转180度 (加上y0.000001是因为旋转180°会默认顺时针)                self.imageButton.transform=CGAffineTransformRotate(self.imageButton.transform, -M_PI+0.000001);

 //平移                self.imageButton.transform=CGAffineTransformTranslate(self.imageButton.transform, 100, 0);

以上都是保存了形变的状态的。如果单独使用不会有问题。但是当我们旋转后再平移的话就发现不是我们想要的结果。如果我们顺时针旋转45度,再向X轴平移100点,那么再界面上就是斜着平移了100点。这是因为transfrom是通过更改坐标系来实现形变的。所以使用时应注意。
0 0