开发者

Transform question: How to move image whilst zooming?

Please can someone help with a simple transform I am attempting...

The code below zooms a thumbnail image into one that fills the screen. The problem is the thumbnail isn't centered (its offset towards the right), so the zoom actually needs to be moving the image towards the left, as it zooms in.

[fullsizeImageButton setTransform:CGAffineTransformMak开发者_StackOverflow社区eScale(.5,.5)];

[UIView beginAnimations:nil context:NULL];

[UIView setAnimationDuration:0.9]; fullsizeImageButton.transform = CGAffineTransformMakeScale(1,1);

[UIView commitAnimations];

Thanks in advance for any help


You must build a bit more complex transform. Scale transform will scale the image relative to current origin (0,0), however, you want to scale relative to image's center. So, you must translate to the center, scale and translate back

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜