如何一次使用CGAffineTransformMakeScale和Rotation? [英] How do I use CGAffineTransformMakeScale and Rotation at once?

查看:121
本文介绍了如何一次使用CGAffineTransformMakeScale和Rotation?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

((UIImageView*)[dsry objectAtIndex:0]).transform = CGAffineTransformMakeRotation(1.57*2);
((UIImageView*)[dsry objectAtIndex:0]).transform = CGAffineTransformMakeScale(.5,.5);

一次只能执行其中一项工作。如何保存转换然后应用另一个?
干杯

Just one of these works at a time. How can I save a transformation and then apply another? Cheers

推荐答案

为了扩展彼得所说的内容,您需要使用如下代码:

To expand upon what Peter said, you would want to use code like the following:

CGAffineTransform newTransform;
newTransform = CGAffineTransformMakeRotation(1.57*2);
((UIImageView*)[dsry objectAtIndex:0]).transform = CGAffineTransformScale(newTransform,.5,.5);

CGAffineTransformMake ...函数从头开始创建新的变换,其他的变换连接变换。视图和图层一次只能应用一个变换,因此这就是您一次在视图上创建多个缩放,旋转和平移效果的方法。

The CGAffineTransformMake... functions create new transforms from scratch, where the others concatenate transforms. Views and layers can only have one transform applied to them at a time, so this is how you create multiple scaling, rotation, and translation effects on a view at once.

你需要注意连接变换的顺序,以达到正确的效果。

You do need to be careful of the order in which transforms are concatenated in order to achieve the correct effect.

这篇关于如何一次使用CGAffineTransformMakeScale和Rotation?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆