How do I position a subview within a principal view?
I created a class in my project and th开发者_运维技巧is class is a subclass of another class; I want place this subview in the principal view, I reduced x and y to make it smaller, but it always appears at the top left, how can I set it in other position?
Would be easier to answer if you posted some code. Most likely, you need to modify the frame
property of your view. frame
is a rectangle (CGRect) that determines the position and size of your view in the coordinate system of its superview. The bounds
property is similar but expresses origin and size in the coord system of itself (e.g. origin is 0,0).
For other layout tips, look at the autoresizingMask
and contentMode
properties of views. In fact, read up on views in general. The Apple docs are good and lots of stuff here about them.
精彩评论