Pages

Monday, March 4, 2013

Get Screen Size of iPhone/iPad

Here is a simple line to get the screen size in xCode.

UIScreen *screen = [UIScreen mainScreen];
CGRect fullScreenRect = screen.bounds;
//This will be used to get the width and height
fullScreenRect.size.widthfullScreenRect.size.height

And For Games, where Cocoas is using

CGSize winSize = [CCDirector sharedDirector].winSize;

NSLog(@" %f, %f", winSize.width, winSize.height);


Swift:

var screenUIScreen = UIScreen.mainScreen()
var fullScreenRect: CGRect = screen.bounds
//This will be used to get the width and height


fullScreenRect.size.widthfullScreenRect.size.height

No comments:

Post a Comment