With Auto Layout, how do I make a UIImageView's size dynamic depending on the image?

后端 未结 8 488
花落未央
花落未央 2020-11-28 21:57

I want my UIImageView to grow or shrink depending on the size of what the actual image it\'s displaying is. But I want it to stay vertically centered and 10pts

8条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-28 22:35

    If you read the docs on UIImageView they say:

    Setting the image property does not change the size of a UIImageView. Call sizeToFit to adjust the size of the view to match the image.

提交回复
热议问题