Reputation: 19418
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...
Upvotes: 14
Views: 43115
Reputation: 3524
However, if the class is UIView itself, then only:
CGFloat height = self.bounds.size.height
Upvotes: 6
Reputation: 279
Have you tried this @Maulik?
CGFloat width = CGRectGetWidth(self.view.bounds);
CGFloat height = CGRectGetHeight(self.view.bounds);
Upvotes: 12
Reputation: 1985
if you want to log it
NSLog(@"My view's frame is: %@", NSStringFromCGRect(myView.frame));
Upvotes: 12