bharath
bharath

Reputation: 14463

How to get width and height of iPhone/iPad using MonoTouch?

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

How to get programmatically?

Upvotes: 24

Views: 16773

Answers (3)

Geert Jan
Geert Jan

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

Tushar patel
Tushar patel

Reputation: 3407

To get width use,

UIScreen.MainScreen.Bounds.Width

To get height use,

UIScreen.MainScreen.Bounds.Height

Upvotes: 9

Dimitris Tavlikos
Dimitris Tavlikos

Reputation: 8170

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

Upvotes: 51

Related Questions