How to get Iphone ViewController program sizes

How to get and set iphone screen sizes and view sizes dynamically .. Suppose I install an image for iphone, it should also match ipad screen.

+4
source share
3 answers

To get the screen size, you can use

CGSize screenSize = [[UIScreen mainScreen] bounds].size; 

to get the size of your view e.g.

 UIViewController* myViewController = [[UIViewController alloc] init]; 

what you can do is similar to the above

 CGSize viewSize = myViewController.view.frame.size; 

to install

 myViewController.view.frame = CGRectMake(x, y, width, height); 
+14
source

to establish

 view.frame = CGRectMake(x, y, width, height); 

and get

 CGRect rect = view.frame; 
+1
source

You can use the viewDidLoad method and write below code in the same.

 self.view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)]; 
0
source

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


All Articles