Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Autolayout hide a view if it becomes too small?

Tags:

ios

autolayout

I have three views (A, B, C) arranged horizontally. A has a fixed width, B has a maximum width, C has a minimum width and will fill all remaining space to the width of the screen.

B is an image, which scales preserving its aspect ratio.

On a large screen, B reaches its maximum size and looks great. On a very small screen, B disappears altogether, which is fine. However, in between the two, we sometimes have B appear as a very small image - just a few pixels wide and too small to make out.

How can I say, "if B is less than 20 pixels wide, hide it altogether"?

(I have to support iOS 7, so I'd prefer a solution that doesn't use UIStackView.)

like image 880
teedyay Avatar asked Jun 01 '16 09:06

teedyay


1 Answers

You might be able to do this with some priority for your constraints. Making them break when they are not satisfying the view, and then also have a constraint with width zero with the "lowest priority".

like image 103
ullstrm Avatar answered Oct 27 '22 03:10

ullstrm