How to get x and y for CGRect to initialize a control using a frame?

I am programming an application for the iPhone, and I am wondering how programmers correctly position the controls without using Interface Builder. Moreover, this is due to the fact that I want to place a couple of controls without using Interface Builder.

Thank!

+3
source share
3 answers

Try using IB to see the coordinates at which you want to place your objects, and then add them to the code. Usually you need to make a trial version and make an error so that everything is correct.

. , 480/2. UIScreen :

(, UIView - , iPhone, iPad, iPad)

myView.center = CGPointMake([[UIScreen mainScreen] bounds].size.width/2, [[UIScreen mainScreen] bounds].size.height/2);
+4

IB, -. iPod/iPhone (320px * 480px).

, x, y.

0

, . IB , , , .

-1
source

Source: https://habr.com/ru/post/1733987/


All Articles