用什么来移动UIView self.frame或self.transform属性? [英] What to use to move UIView self.frame or self.transform property?

查看:218
本文介绍了用什么来移动UIView self.frame或self.transform属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有点困惑这个问题。



我知道我可以移动视图来改变他们的 self.frame.origin ,但我发现有一个名为transform的属性,我认为这是为了在屏幕上移动我的视图等等。

也许我不明白这一点。



所以我想知道:我必须使用哪个属性来移动 UIView (或它的子类)以及另一个属性一?
或者,如果我完全错了,请告诉我正确的方法。

解决方案

UIView的框架属性定义它相对于它的superview的位置。如果你想移动一个视图,这就是你想要的方式。



转换属性基本上应用 CGAffineTransform 到视图的后备层。在大多数情况下,如果您只想移动视图,则不希望使用此属性。



在旋转或缩放图层(即视图)时,转换属性非常有用。有时,当你应用旋转时,你还需要移动它以使其保持它的位置,在这种情况下,你将使用 transform 属性来移动它。 / p>

I'm a little confused this question.

I know that I can move views changing their self.frame.origin, but I found that there is a property called transform and I thought that this is for moving my view on the screen and etc.
Maybe I don't understand that a little.

So I want to know: which property I must use for moving UIView (or it's subclasses) and for what is another one? Or if I'm completely wrong show me the right way please.

解决方案

The frame property of a UIView defines it's position relative to it's superview. If you want to move a view, that's the way to go.

The transform property basically applies a CGAffineTransform to the backing layer of the view. In most cases you don't want to use this property if you just want to move the view.

The transform property is useful when it comes to rotating or scaling the layer (i.e. view). Sometimes, when you apply a rotation, you also need to move it to make it "keep" it's postion, in that case you would use the transform property to move it.

这篇关于用什么来移动UIView self.frame或self.transform属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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