详解IOSUITableViewCell的imageView大小更改

详解IOS UITableViewCell 的 imageView大小更改

创新互联专业为企业提供乌拉特前网站建设、乌拉特前做网站、乌拉特前网站设计、乌拉特前网站制作等企业网站建设、网页设计与制作、乌拉特前企业网站模板建站服务,十载乌拉特前做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。

实例代码:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

  static NSString *CellIdentifier = @"Cell";

  UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

  if(cell == nil){
    cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier];
    cell.textLabel.text = [self.arrStr objectAtIndex:indexPath.row];

    UIImage *img = [UIImage imageNamed:[self.arrImg objectAtIndex:indexPath.row]];
    cell.imageView.image = img;

    //iOS UITableViewCell 的 imageView大小更改
    CGSize itemSize = CGSizeMake(img.size.width *2/3, img.size.height *2/3);
    UIGraphicsBeginImageContext(itemSize);
    CGRect imageRect = CGRectMake(0.0, 0.0, itemSize.width, itemSize.height);
    [cell.imageView.image drawInRect:imageRect];
    cell.imageView.image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
  }
  return cell;


}

以上就是关于IOS UITableViewCell 的 imageView大小更改的实例,本站还有很多关于IOS 开发的文章,欢迎大家搜索参阅,

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!


分享题目:详解IOSUITableViewCell的imageView大小更改
网站地址:http://bzwzjz.com/article/jjceje.html

其他资讯

Copyright © 2007-2020 广东宝晨空调科技有限公司 All Rights Reserved 粤ICP备2022107769号
友情链接: 网站建设方案 定制网站设计 成都网站设计 成都网站建设公司 手机网站制作 成都企业网站设计 手机网站建设 成都定制网站建设 成都企业网站建设公司 成都网站设计 网站制作 重庆网站建设 成都网站设计 H5网站制作 高端网站设计 做网站设计 企业网站建设 专业网站设计 成都品牌网站建设 外贸网站设计方案 网站设计制作报价 响应式网站建设