Yes and no. In AutoLayout, you cannot set the size limit for a UIView, however you can prevent the UIView from “shrinking” according to its internal size .
This will effectively limit the view, while avoiding the lack of a parent view, so that the child view has a certain size (and thus removes the “Auto” part of AutoLayout).
To set these priorities, you use: setContentCompressionResistancePriority:forAxis:
From Apple UIView Documentation :
Custom views should set default values for both orientations when creating based on their contents, usually for NSLayoutPriorityDefaultLow or NSLayoutPriorityDefaultHigh. When creating user interfaces, the layout designer can change these priorities for certain views when the overall layout design requires different compromises than the natural priorities of the views used in the interface.
Subclasses should not override this method.
So, now we know how to assign priority in order to avoid our view becoming smaller than its internal size, but how to set our own size?
Well, if you use the standard user interface element, you are already configured! But if your UIView is normal, you need to override - (CGSize)intrinsicContentSize to return the correct size. Here you can measure any subviews that need to calculate the correct sizes, or if you use art / constant size elements, you can return a solid value.
Again, from the Apple UIView Documentation :
Custom views typically contain content displayed on a screen that the layout system is not aware of. Overriding this method allows the custom view to communicate with the layout, what size it would like to use on its content. This internal size must be independent of the content frame, because there is no way to dynamically link the changed width to the layout system based on the changed height, for example.
Apple strongly recommends that you don’t check anything outside of your UIView (for example, getting the size of your superview and adjusting it), as this is not what AutoLayout is for (and can lead to a bad headache along the way).