美文网首页
iOS UITableViewCell 中 固定imageVie

iOS UITableViewCell 中 固定imageVie

作者: iOS劝退师 | 来源:发表于2018-05-21 16:50 被阅读0次

cell.imageView.image的大小 会随着Cell的高度而变化,不同的图片显示的也不一样

解决方案:

//1、首先对image付值

cell.imageView.image=[UIImage imageNamed:@"imagename"];

//2、调整大小

      CGSize itemSize = CGSizeMake(40, 40);

      UIGraphicsBeginImageContextWithOptions(itemSize, NO, UIScreen.mainScreen.scale);

      CGRect imageRect = CGRectMake(0.0, 0.0, itemSize.width, itemSize.height);

      [cell.imageView.image drawInRect:imageRect];

      cell.imageView.image = UIGraphicsGetImageFromCurrentImageContext();

      UIGraphicsEndImageContext();

相关文章

网友评论

      本文标题:iOS UITableViewCell 中 固定imageVie

      本文链接:https://www.haomeiwen.com/subject/rphqjftx.html