开发者

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;

How can I curreclty crop/resize image in tableviewcells to fit properly

expecting

How can I curreclty crop/resize image in tableviewcells to fit properly

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜