0

I have an image 1024x1024 and I want resize this image to fit into a tableView Cell. I have used this lines of code:

+ (UIImage*)imageWithImage:(UIImage*)image scaledToSize:(CGSize)newSize {

   //New size is the size of the cell for me
   UIGraphicsBeginImageContext(newSize);
   [image drawInRect:CGRectMake(0,0,newSize.width,newSize.height)];
   UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
   UIGraphicsEndImageContext();
   NSData *imageData = UIImagePNGRepresentation(img);
   UIImage *imgFinal=[UIImage imageWithData:imageData];

   return imgFinal;

}

The problem is, when I visualize this image on the screen of Iphone6 or Iphone6+ the image appear blurred and a little bit pixelated. Can you help me?

mrcf
  • 149
  • 2
  • 9

1 Answers1

0

You can also set content mode as

cell.imageView.contentMode = UIViewContentModeScaleAspectFit;

For more info refer below link-

iOS - UITableViewCell image adjust/resize

Community
  • 1
  • 1
Sanjay Mohnani
  • 5,947
  • 30
  • 46