UIImage aspect fit and align to top
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.
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.
The solution is to set the contentMode on the imageView property of the UIButton. The UIButton has to be created with custom type for this to work I believe (otherwise nil is returned for this property).