自定义网络请求图片的大小
2016-03-07 本文已影响428人
且行且珍惜_iOS
NSURL *url = [NSURL URLWithString:[[self.imageSource objectAtIndex:indexPath.section] objectAtIndex:indexPath.row]];
UIImage *icon = [UIImage imageWithData:[NSData dataWithContentsOfURL:url]];
CGSize itemSize = CGSizeMake(30, 30);
UIGraphicsBeginImageContextWithOptions(itemSize, NO,0.0);
CGRect imageRect = CGRectMake(0.0, 0.0, itemSize.width, itemSize.height);
[icon drawInRect:imageRect];
cell.imageView.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();