这篇文章主要介绍了详解IOS UITableViewCell 的 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 开发的文章,欢迎大家搜索参阅,
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
织梦狗教程
本文标题为:详解IOS UITableViewCell 的 imageView大小更改
基础教程推荐
猜你喜欢
- iOS开发教程之XLForm的基本使用方法 2023-05-01
- Android多返回栈技术 2023-04-15
- Flutter手势密码的实现示例(附demo) 2023-04-11
- Flutter绘图组件之CustomPaint使用详解 2023-05-12
- Android中的webview监听每次URL变化实例 2023-01-23
- IOS应用内跳转系统设置相关界面的方法 2022-11-20
- 解决Android Studio突然不显示logcat日志的问题 2023-02-04
- Android开发使用RecyclerView添加点击事件实例详解 2023-06-15
- IOS 播放系统提示音使用总结(AudioToolbox) 2023-03-01
- android studio按钮监听的5种方法实例详解 2023-01-12
