Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom UIView with dynamic height on Storyboard

I want to implement custom UIView (from code) with dynamic height, based on content (similar to UILabel). I can do this by implementing intrinsicContentSize - and it seems to work correctly, but...

When I am adding my custom view to view controller on storyboard, I've got error (missing height constraint) - even when during launch everything seems to resize correctly.

When you add UILabel to storyboard you don't have to specify height, there are no errors. How to achieve the same behavior for custom UIView (I want to use it in storyboard)?

like image 466
Piotr Avatar asked Dec 12 '15 22:12

Piotr


1 Answers

If someone will need the solution:

I just found that there is "Intrinsic Size" property in Storyboard - you just need to set it to "Placeholder" and set some values just for Interface Builder...

enter image description here

like image 194
Piotr Avatar answered Oct 15 '22 22:10

Piotr