Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get the height of UIView

Tags:

iphone

uiview

I am having trouble in getting UIView's height. I am trying to get the height and (x,y) of my UIView. The view is add as subview of Other view

float y = optionalView.frame.size.height;
    NSLog(@"%.1f",y);

but it always return 0.0 . need guidance.

Thanks...

like image 613
Maulik Avatar asked Apr 07 '11 06:04

Maulik


2 Answers

Have you tried this @Maulik?

CGFloat width = CGRectGetWidth(self.view.bounds);
CGFloat height = CGRectGetHeight(self.view.bounds);
like image 143
civiac Avatar answered Oct 02 '22 12:10

civiac


However, if the class is UIView itself, then only:

CGFloat height = self.bounds.size.height
like image 41
Darius Miliauskas Avatar answered Oct 02 '22 12:10

Darius Miliauskas