1.通过设置 图形上下文
1
2
3
4
5
6
7
8
|
CGSize itemSize = CGSizeMake(40, 40);
UIGraphicsBeginImageContext(itemSize);
CGRect imageRect = CGRectMake(0.0, 0.0, itemSize.width, itemSize.height);
[cell.imageView.image drawInRect:imageRect];
cell.imageView.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
|
2. 只有在UITableViewCell子类中重写layoutSubviews方法去改变这些值,举例
-(void)layoutSubviews
{
[super layoutSubviews];
[self.imageView setFrame:CGRectMake(10, 10,29, 29)];
self.imageView.contentMode = UIViewContentModeScaleAspectFit;
}