[Solved] auto layout not working properly for image view and label when both are align together


Assuming that your layout looks something like this, at the top there is a image, below that there is a label whose leading should be equal to the top image view leading. And below the label there should be another view whose top space should vary according to the label height.

Solution for this goes like this,
For the top image view pin image view to top of its superview with some space as per your requirements and centre it horizontally.
For the label pin it to image view bottom and label top with some space as per your requirements. Also add constraint to leading of label to leading of top image view and trailing of label to trailing of image view as 0 points.
For the view below the label pin label bottom to view top with some space as per your requirements. Then add leading and trailing constraints with respect to top image view similar to the constraints added to the label trailing and leading.

solved auto layout not working properly for image view and label when both are align together