I want to center my UIImageView and UILabel like the pic below. I used a container to contain UIImageView and UILabel,but the container does not suit the width of UIImageView and UILabel.So I need to set the width of the container.Is there any method to solve the problem without set the width or calculate the view's width? Here's the picture:
There are four view in action:
The views are in following hierarchy:
I assume that the outer view gets its width and height from other constraints.
What I see from the image you provided that image is taller than label, keeping that in mind following constrains could achieve what you want: