I understand that intrinisicContentSize
is part of the AutoLayout API, but other than that, I'm seeing lots of functionality overlap between it and the -sizeThatFits
method.
In what circumstance should one be used over the other? When I'm subclassing a UIView
, which should I override to make sure my view is sized to its subviews?. Can you give an example of what a typical overridden method would look like for both?
intrinsicContentSize
was added in iOS 6 and as you mentioned is part of the AutoLayout API so anything which supports an earlier iOS won't have access to it. Also, if you turn off auto layout, it doesn't matter which you use and many people who are used to using sizeThatFits
will still use it for a while... at least until auto layout gain greater adoption.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With