24

I need to get the width and height of iPhone/iPad using MonoTouch.

How to get programmatically?

3 Answers 3

51

To get the screen size of the device, call UIScreen.MainScreen.Bounds. It returns a RectangleF with the screen size.

9

To get width use,

UIScreen.MainScreen.Bounds.Width

To get height use,

UIScreen.MainScreen.Bounds.Height
4

You use UIScreen.MainScreen.Bounds to get the point size of the screen. It returns the point value of the screen, not the pixel size.

UIScreen.MainScreen.Scale which return 1.0 pixels per point for non-retina displays, and 2.0 pixels per point for retina displays.

UIScreen.MainScreen.Bounds.Size.Width * UIScreen.MainScreen.Scale will get the width in pixels.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.