Reputation: 295
I have a label in a View Controller scene inside a root view. I set the constraint of the height to 30 using the Pins button right below. Everything looks pretty in the storyboard.
But when I want to get the size of the element inside my code I always get the value 21. I tried refLabel.bounds.size.height
and refLabel.frame.height
. I call this in the override func viewDidLoad(){
super.viewDidLoad()
function of the corresponding class.
Has this something to do with the intrinsic content size?
Upvotes: 0
Views: 1190
Reputation: 811
Try this code
refLabel.layoutIfNeeded()
let height = refLabel.frame.size.height
print("right height is \(height)")
Upvotes: 1