如何正确裁剪/调整表格视图单元格中的图像以使其适合

时间:2011-06-13 15:25:19

标签: iphone uitableview uiview uiimage

我正在尝试在表格视图单元格中显示图像集。所有图像都是不同的大小。我想裁剪或调整图片大小,以便在照片应用中看起来像。我怎样才能做到这一点 谢谢,
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

view.frame = CGRectMake(0, 0, 70 , 70);//not working view.bounds = CGRectMake(0, 0, 70 , 70);//not working

我的结果;

enter image description here

期待 enter image description here 照片应用程序很好地将每张图像更改为均匀尺寸。

2 个答案:

答案 0 :(得分:1)

使用以下方法裁剪图像,您需要传递裁剪矩形。

CGImageRef myImageRef = CGImageCreateWithImageInRect([largeImage CGImage], myCropRect);
myImage = [UIImage imageWithCGImage:myImageRef ]]; 
CGImageRelease(myImageRef );

答案 1 :(得分:0)

使用NYXImagesUtilities中的UIImage+Resizing类别。例如:

UIImage* cropped = [myImage cropToSize:(CGSize){75, 75} usingMode:NYXCropModeCenter];

do it yourself

相关问题