所以不可变更
可以用这种方法改
- UIImage *icon = [UIImage imageNamed:item.icon];
- UIImageView *imgview = [[UIImageView alloc]initWithImage:icon];
- imgview.frame = CGRectMake(5, 10, 15, 21);
- [cell.contentView addSubview:imgview];
- cell.indentationLevel = 2; //缩进层级
- cell.indentationWidth = 10.0f; //每次缩进寛
NSString *imageStr = [NSString stringWithFormat:@"%@%@",kPreURLA,[dic objectForKey:@"telImg"]];
NSURL *imageURL = [NSURL URLWithString:imageStr];
UIImage *tempImage = [UIImage imageWithData:[NSData dataWithContentsOfURL:imageURL]];
CGFloat height = tempImage.size.height;
CGFloat width = tempImage.size.width;
CGFloat bili = height / width;
_telImgView = [[UIImageView alloc] initWithFrame:CGRectMake(5, 20, image_with, 20)];
// 图片居中显示
_telImgView.contentMode = UIViewContentModeCenter;
// 超出_telImgView范围的图片部分不显示
_telImgView.layer.masksToBounds = YES;
_telImgView.image = [self OriginImage:tempImage scaleToSize:CGSizeMake(image_with, image_with * bili)];
// 改变图片大小
-(UIImage*) OriginImage:(UIImage *)image scaleToSize:(CGSize)size {
UIGraphicsBeginImageContext(size); //size 为CGSize类型,即你所需要的图片尺寸
[image drawInRect:CGRectMake(0, 0, size.width, size.height)];
UIImage* scaledImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return scaledImage; //返回的就是已经改变的图片
}