?? iOS開發(fā)中,有時候會有需求要改變UITableViewCell中cell.imageView.image
的位置或者大小,當然可以用自定義cell的方式實現(xiàn),該種方式不再贅述.然而當我們已經(jīng)用了系統(tǒng)的cell前提下,再因為這個需求換成自定義的cell會很麻煩,在開發(fā)中可以通過重新繪制cell.imageView.image
來實現(xiàn)需求
代碼粘貼如下:
cell.imageView.image = image;
CGSize itemSize;
if (indexPath.row == 2) {
itemSize = CGSizeMake(35, 13);
}else
{
itemSize = CGSizeMake(35, 35);
}
UIGraphicsBeginImageContextWithOptions(itemSize, NO, UIScreen.mainScreen.scale);
CGRect imageRect = CGRectMake(0.0, 0.0, itemSize.width, itemSize.height);
[cell.imageView.image drawInRect:imageRect];//改變系統(tǒng)自帶控件的大小
cell.imageView.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
希望能在開發(fā)中帶來一點兒便利.