最近调整了自己程序的界面,觉得之前的cell.imageView尺寸太大了,又不想改动太大,就找了个简单的方法。记录一下。
UIImage *Image;
Image = [UIImage imageNamed:@"defaultPic"];
CGSize itemSize = CGSizeMake(60, 70);
UIGraphicsBeginImageContextWithOptions(itemSize, NO ,0.0);
CGRect imageRect = CGRectMake(0.0, 0.0, itemSize.width, itemSize.height);
[Image drawInRect:imageRect];
cell.imageView.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImage *Image;
Image = [UIImage imageNamed:@"defaultPic"];
CGSize itemSize = CGSizeMake(60, 70);
UIGraphicsBeginImageContextWithOptions(itemSize, NO ,0.0);
CGRect imageRect = CGRectMake(0.0, 0.0, itemSize.width, itemSize.height);
[Image drawInRect:imageRect];
cell.imageView.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();