用什么来移动UIView self.frame或self.transform属性? [英] What to use to move UIView self.frame or self.transform property?
问题描述
我有点困惑这个问题。
我知道我可以移动视图来改变他们的 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屋!