Lasse Madsen
Lasse Madsen

Reputation: 602

Get size of UIView

I have a UIView and some Buttons on a Xamarin Page, and I need to find the Width and Height of the UIView not the Frame.

Are there any ways to solve this?

Upvotes: 2

Views: 4605

Answers (2)

Alanc Liu
Alanc Liu

Reputation: 1294

If you want to get the view's size:

float viewWidth = view.Frame.Width;
float viewHeight = view.Frame.Height;

If you want to get the whole page's size:

float screenWidth = UIScreen.MainScreen.Bounds.Width;
float screenHeight = UIScreen.MainScreen.Bounds.Height;

Hope it can help you.

Upvotes: 0

wg_hjl
wg_hjl

Reputation: 545

int width = self.view.frame.size.width
int height = self.view.frame.size.height

So when you get the frame you can get the width and the height.

Upvotes: 4

Related Questions