tableView的Cell调整imageView的大小

来源:互联网 发布:sai绘画软件下载 编辑:程序博客网 时间:2024/05/17 07:06
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CellIdentifier"];    if(!cell){        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"CellIdentifier"];    }        UserModel *user = self.dataSource[indexPath.row];    [cell.imageView setImage:[UIImage imageNamed:user.imageName]];    //2、调整大小    CGSize itemSize = CGSizeMake(60, 60);    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();            [cell.textLabel setText:user.name];    [cell.detailTextLabel setText:user.message];        return cell;}





0 0
原创粉丝点击