I have a Label which takes dynamicaly some data from database. These data are strings which can sometimes be 3-4-5 rows etc. So this labe is inside a UIView.
--UIView
--Label
How can i make the UIView
to take the certain height of the Label dynamicaly??
I know this is late answer, but it might help someone else.
To make the Dynamic height for UIView follow the simple steps in Storyboard
This technique works with other views inside this UIView. The thing is you must specify bottom constraints for the views present inside this UIView.
}
}
Give leading ,top, trailing and height constraint for view .
And height outlet of view name as constraint [because i used outlet name constraint]
first calculate the size of label with the text it contains, using this function
and then apply the height of returned size to the UIView like this
Below code will resolved your issue :
//Adjust View Height
you can just do it with storyboard this pics
set the label height relation to greater than or equal
and set the view height relation to greater than or equal
it work like a magic
Bellow is working solution of your problem. I used
autoLayout
. IntestView
you don't setheightAnchor