Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What to use to move UIView self.frame or self.transform property?

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.

like image 970
Dima Deplov Avatar asked Dec 01 '22 21:12

Dima Deplov


1 Answers

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.

like image 95
Tobi Avatar answered Dec 05 '22 10:12

Tobi