简体   繁体   中英

How to hide an UIImageView with Aspect Ratio autolayout constraint?

I have a custom UITableViewCell where I have an image at the top with an Aspect Ratio constraint, and labels under my image with constraints relative to my image.

I wan't to be able to hide my image so all the labels under are moved to the top where my image is.

With a fixed height constraint, I could create an IBOutlet and set the constant to 0, and it would work, but with an Aspect Ratio constraint, I don't know how to achieve this.

Thanks!

The only solution that I see here is - when you need to hide it, than you should:

1) Get width of you view 2) set aspect ratio constraint active = NO 3) create width constraint from value getted before 4) create height constraint with constant = 0 5) add this two constraints(if doing from code) 6) Animate

As well you can create width and height constraints in builder with aspect ratio constraint and just manipulate with property active

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM