24

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

How to get programmatically?

Fattie
  • 27,874
  • 70
  • 431
  • 719
bharath
  • 14,283
  • 16
  • 57
  • 95

3 Answers3

51

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

Dimitris Tavlikos
  • 8,170
  • 1
  • 27
  • 31
9

To get width use,

UIScreen.MainScreen.Bounds.Width

To get height use,

UIScreen.MainScreen.Bounds.Height
Tushar patel
  • 3,279
  • 3
  • 27
  • 30
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.

Geert Jan
  • 408
  • 1
  • 6
  • 22