UIView provides for the \"aspect fit\" content mode. However, I\'ve subclasses UIView and would like to draw a UIImage using drawInRect with an aspect fit. Is there any way
this might help you, give it a try
UIImage *logoImage = [UIImage imageNamed:@"logo.png"];
float newHeight = ((logoImage.size.height / logoImage.size.width) * 100.0);
CGRect newLogoImageRect = CGRectMake(0, 0, 80.0, newHeight);
[logoImage drawInRect:newLogoImageRect];
specify your maximum height instead of 100.0 and maximum width instead of 80.0