Reputation: 748
I am pretty new to iOS dev. I am trying to create a view with a UILabel
and a UITableView
. The UILabel
is used to display some header text & the tableview is positioned below the header & it covers the remaining portion of the screen.
I am creating this view using code & not the storyboard approach. So I need to specify the height & width of my tableview as constraints. For the width I have set a constraint where it matches the width of the container view. However for the height I wish to use the following equation:
tableview's height
= container view's height
- UILabel's height
For this I need to know how I can get the container's & the UILabel
's height via code. I tried the following approach-
CGFloat header_height=lblHeader.bounds.size.height;
But this gives the same height as the container view's height .i.e. 460. Can someone please explain how I can get the height of the UIlabel
view?
Upvotes: 0
Views: 529
Reputation: 2835
To get the height of the UILabel do this instead:
CGFloat header_height = lblHeader.frame.size.height;
Frames and bounds are not the same.
Cocoa: What's the difference between the frame and the bounds?
Upvotes: 1