Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Iphone ViewController sizes programmatically

Tags:

ios

iphone

How to get and set iphone screen sizes and View sizes dynamically.. Suppose i'm setting imageview for an iphone, it should also fits to the ipad screen..

like image 793
veeramani Avatar asked Dec 01 '22 23:12

veeramani


2 Answers

To get the screen size, you can use

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

to get the size of your view, for example

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

what you can do is similar to the one above

CGSize viewSize = myViewController.view.frame.size;

To set

myViewController.view.frame = CGRectMake(x, y, width, height);
like image 57
X Slash Avatar answered Dec 17 '22 09:12

X Slash


to set use

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

and to get

CGRect rect = view.frame;
like image 34
Inder Kumar Rathore Avatar answered Dec 17 '22 10:12

Inder Kumar Rathore