I have added an Imageview on UIView, and set the property AspectToFit. According to app requirement, I need to add one more image on the imageview.
float width;
float height;
float x;
float y;
CGSize imageViewSize = self.getImageView.bounds.size;// self.getImageView.frame.size;
CGSize imageSize = self.getImage.size;
CGFloat minFactor = imageViewSize.width / imageSize.width;
if (imageViewSize.height / imageSize.height < minFactor)
{
minFactor = imageViewSize.height / imageSize.height;
}
CGRect frame = self.getImageView.frame;
NSLog(@"view height..%@",NSStringFromCGRect (frame));
CGSize resultSize = CGSizeMake(minFactor * imageSize.width, minFactor * imageSize.height);
UIImage *newimage = [self imageWithImage:self.getImage scaledToSize:resultSize];
float mainwidth = imageViewSize.width;
float mainheight = imageViewSize.height;
float imagewidth = newimage.size.width;
float imageheight = newimage.size.height;
_widthdiff = mainwidth-imagewidth;
_heightdiff = mainheight-imageheight;
x = self.view.frame.size.width-width-0-_widthdiff/2;
y = self.view.frame.size.height-height-116-_heightdiff/2;
imageview = [[UIImageView alloc]
initWithFrame:CGRectMake(x, y, width, height)];
[imageview setContentMode:UIViewContentModeScaleAspectFit];
This code is working fine for all the devices except iPhone (iPhone 6 Plus, iPone 7 Plus). As I can see there is issue only in Plus size of devices.
Is there a different to calculate the difference or ratio between imageview and proper image? Please advice.