How can I curreclty crop/resize image in tableviewcells to fit properly
I am trying t开发者_如何学编程o display set of images in table view cell. All the images are different size. I want to crop or resize images so as to look like in photos app. How can I achieve this.
Thanks, Shakthi
cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
cell.imageView.image = image;
UIImageView * view=cell.imageView;
view.frame = CGRectMake(0, 0, 70 , 70);//not working
view.bounds = CGRectMake(0, 0, 70 , 70);//not working
My result;
expecting
Photo application nicely changed every images to uniform size.Use below to crop the image , you need to pass the crop rect.
CGImageRef myImageRef = CGImageCreateWithImageInRect([largeImage CGImage], myCropRect);
myImage = [UIImage imageWithCGImage:myImageRef ]];
CGImageRelease(myImageRef );
Use the UIImage+Resizing
category from NYXImagesUtilities. Example:
UIImage* cropped = [myImage cropToSize:(CGSize){75, 75} usingMode:NYXCropModeCenter];
or do it yourself.
精彩评论