问题
I am playing with autoLayout constraints in iOS
My use case is this way,
I will better explain with images
I am using a custom cell for UITableViewCell, through autolayout I have set constraints for text and divider line below and they obey autolayout constraints. Now you can see the yellow vertical strip on the left.
I have not set any constraints for it, so when the cell height is normal, it covers the whole cell, but when cell height increases, it doesnt increase and fill the whole cell. I am not able to make its height flexible w.r.t to cell.
I want to expand the yellow strip to cover the whole cell.
So how I can achieve this.
回答1:
You can make height of yellow strip flexible by setting 2 constraints.
Set both top space and bottom space to container (cell's content view) to 0. Ensure there is no constant height constraint for it.
回答2:
You need to set constraints to the yellow view. By default it would apply its own constraints at runtime.
To the yellow view add TOP , BOTTOM , LEADING , and TRAILING constraint. DO NOT ADD A HEIGHT constraint.
Make sure the TOP and BOTTOM constraints of the yellow view are pinned to the cell's content view.
Let me know if it works.
Cheers
来源:https://stackoverflow.com/questions/27103760/applying-autolayout-constraints-to-multiple-objects