为什么自动布局中的CGAffineTransformRotate会移动动画视图? [英] why CGAffineTransformRotate in autolayout will shift the animated view?

查看:137
本文介绍了为什么自动布局中的CGAffineTransformRotate会移动动画视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用以下代码旋转imageView:

I want to rotate a imageView using the following code:

[UIView animateWithDuration:.25 animations:^{
    self.imageView.transform = CGAffineTransformRotate(self.plusView.transform, M_PI_4);
}];

有线的事情是:如果我在没有自动布局的情况下运行此代码,那么每件事情都可以。但是当使用自动布局时,图像视图会在旋转之前移动一个垃圾像素,为什么?

the wired thing is that: if I run this code without auto layout, every thing is fine. but when using autolayout, the image view shift a litter pixel before rotate, why?

推荐答案

在Xcode 5中使用自动布局时,您需要添加约束来固定其容器中imageView的水平中心和垂直中心。如果您使用的是故事板,则可以使用约束选项轻松完成。如果您不希望imageView自动调整大小,您还需要使用约束来修复宽度和高度。

When using auto layout in Xcode 5, you need to add a constraint to fix the horizontal center and vertical center of the imageView in its container. If you are using storyboards, this can be easily done with the constraints options. You will also need to fix the width and height with constraints if you don't want the imageView auto-resized.

这篇关于为什么自动布局中的CGAffineTransformRotate会移动动画视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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