UIImage aspect fit and align to top

Jacksonkr picture Jacksonkr · Jun 14, 2012 · Viewed 42.2k times · Source

It looks like aspect fit aligns the image to the bottom of the frame by default. Is there a way to override the alignment while keeping aspect fit intact?

** EDIT **

This question predates auto layout. In fact, auto layout was being revealed in WWDC 2012 the same week this question was asked

Answer

Mundi picture Mundi · Jun 15, 2012

In short, you cannot do this with a UIImageView.

One solution is to subclass a UIView containing an UIImageView and change its frame according to image size. For example, you can find one version here.