UIView在使用CGAffineTransformMakeScale进行缩放时旋转 [英] UIView rotates while scaling using CGAffineTransformMakeScale

查看:86
本文介绍了UIView在使用CGAffineTransformMakeScale进行缩放时旋转的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用CGAffineTransformMakeScale将UIView从0.1缩放到1.0。

Im using CGAffineTransformMakeScale to scale a UIView from 0.1 to 1.0.

问题是视图在缩放动画时也在旋转。所以它以1.0和90º的旋转结束。

The problem is that the view is also rotating while the scaling is being animated. So it ends with a scale of 1.0 AND 90º of rotation.

[self presentModalViewController:slideTwoViewController animated: NO];
[slideTwoViewController.view setTransform:CGAffineTransformMakeScale(0.1,0.1)];
[UIView beginAnimations: nil context: nil];
[UIView setAnimationDuration:2.0];
[slideTwoViewController.view setTransform:CGAffineTransformMakeScale(1.0,1.0)];
[UIView commitAnimations];

初始应用程序方向是横向左侧。因此,当动画结束时,UIView看起来像是肖像。

The initial application orientation is landscape left. So when the animation ends the UIView looks like in portrait.

这应该发生吗?我错过了什么吗?

Is this supposed to happen? am I missing something?

谢谢

推荐答案

我打赌,视图已经有了变换集,你用新的变换覆盖它,它是动画的差异。

My bet, is the view already have a transform set and you are overwriting it with the new transform and it is animating the difference.

尝试使用以下函数:

CGAffineTransformScale(<#CGAffineTransform t#>, <#CGFloat sx#>, <#CGFloat sy#>)

使用此函数,您传递原始转换 slideTwoViewController.view.transform 并且您的比例因子。

With this function, you pass the original transform slideTwoViewController.view.transform and your scale factor.

slideTwoViewController.view.transform = CGAffineTransformScale(slideTwoViewController.view.transform, 0.1, 0.1);

这篇关于UIView在使用CGAffineTransformMakeScale进行缩放时旋转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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