0

Please check the attached images in order to understand the issue in brief.enter image description here

Please note the size of the X character and the circle character . The images for both the characters are equal in size , but due to the shape of the second character it appears a bit smaller. I know i can use another image for the second character but then it spoils the shape of the character . So can any one suggest me some way through which i can redraw the content of UIImage to be equal in both the image views.

Singh
  • 2,151
  • 3
  • 15
  • 30

3 Answers3

0

Use UIImageView property AspectFit to set image content from xib, For example:

imageView.contentMode = UIViewContentModeCenter;


if (imageView.bounds.size.width > image.size.width && imageView.bounds.size.height >image.size.height) 
{
  imageView.contentMode = UIViewContentModeScaleAspectFit;
} 
David L
  • 32,885
  • 8
  • 62
  • 93
raghu_dev
  • 91
  • 11
0

Try this :

imageView.contentMode = UIViewContentModeScaleAspectFit;
imageView.clipsToBounds = YES;
Matt
  • 17,290
  • 7
  • 57
  • 71
Vineet Singh
  • 4,009
  • 1
  • 28
  • 39
0

If you want to add some "small zooming" in runtime according to the image displayed, but keep your image views same sized in the xib, use

#import <QuartzCore/QuartzCore.h>

and then in the function that chooses what image to present:

float scale = 1.0f;
select (myImageType) 
{
   case 1: scale = 1.1f;break;
   case 2: scale = 1.162f;break;
   default: scale = 1.0f
}
myImageView.transform = CGAffineTransformMakeScale(scale,scale);
..
myImageView.image = myUIimageToShow;
RabinDev
  • 658
  • 3
  • 13