如何一次使用CGAffineTransformMakeScale和Rotation? [英] How do I use CGAffineTransformMakeScale and Rotation at once?
问题描述
((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屋!