Reputation: 14463
I need to get the width and height of iPhone/iPad using MonoTouch.
How to get programmatically?
Upvotes: 24
Views: 16773
Reputation: 428
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.
Upvotes: 4
Reputation: 3407
To get width use,
UIScreen.MainScreen.Bounds.Width
To get height use,
UIScreen.MainScreen.Bounds.Height
Upvotes: 9
Reputation: 8170
To get the screen size of the device, call UIScreen.MainScreen.Bounds
. It returns a RectangleF
with the screen size.
Upvotes: 51