UITableViewCell中设置不同图片尺寸相同以及设置图片为圆形的方法
来源:互联网 发布:vx软件 编辑:程序博客网 时间:2024/06/12 14:47
一、UITableViewCell中设置不同图片尺寸相同
// 图片尺寸不一样 修改cell左侧显示图片大小的方法 UIGraphics---
<span style="font-size:14px;font-family: KaiTi_GB2312; color: rgb(204, 153, 51);"> </span><span style="font-size:18px;color:#333333;font-family: SimSun;"> </span><span style="font-family:System;font-size:14px;color:#333333;">UIImage *icon = [UIImage imageNamed:[NSString stringWithFormat:@"%@", model.singerHeaderName]];; CGSize itemSize = CGSizeMake(70, 70); UIGraphicsBeginImageContext(itemSize); CGRect imageRect = CGRectMake(0, 0, itemSize.width, itemSize.height); [icon drawInRect:imageRect]; cell.imageView.image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext();</span>
本人暂时没有找到其他的方法,现在用的自定义cell 来实现的,有朋友知道的话可以交流下
<span style="font-size:14px;">- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { self.iv = [[UIImageView alloc]initWithFrame:CGRectMake(10, 5, 40, 40)]; self.iv.backgroundColor = [UIColor clearColor]; self.iv.layer.cornerRadius = CGRectGetWidth(self.iv.frame)/2; self.iv.layer.masksToBounds = YES; [self.contentView addSubview:self.iv]; UIImage *image = [[UIImage alloc]init]; self.iv.image = image; self.nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(self.iv.frame)+5, 5, CGRectGetWidth([UIScreen mainScreen].bounds)-CGRectGetMaxX(self.iv.frame)-5, 15)]; self.nameLabel.backgroundColor = [UIColor clearColor]; self.nameLabel.font = [UIFont systemFontOfSize:15]; [self.contentView addSubview:self.nameLabel]; self.titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(self.iv.frame)+5, 25, CGRectGetWidth([UIScreen mainScreen].bounds)-CGRectGetMaxX(self.iv.frame)-5, 15)]; self.titleLabel.backgroundColor = [UIColor clearColor]; self.titleLabel.font = [UIFont systemFontOfSize:15]; [self.contentView addSubview:self.titleLabel]; } return self;}</span>
示例图片:图一为设置不同尺寸的图片为相同的尺寸,图二为自定义cell,使得image为圆形,似QQ界面
0 0
- UITableViewCell中设置不同图片尺寸相同以及设置图片为圆形的方法
- UITableViewCell中设置动态大小的圆形imageview
- ios设置图片为圆形
- 设置圆形的图片 代码方法
- Android设置圆形组件以及在组件中设置图标或文字的2中方法
- android中设置圆形图片
- Qt QPushButton圆形图片设置为背景
- iOS为多张图片设置相同的大小
- html5设置圆形图片2种方法
- 将“Cocos2dx-截屏并设置图片尺寸 ”中cocos2d-x代码转换为2.2的代码
- Android Glide设置默认图片、异常图片为圆形图片
- Android布局中设置圆形图片
- ImageLodar设置圆形图片
- 设置圆形图片
- Picasso 设置圆形图片
- 设置圆形图片
- Picasso设置圆形图片
- Android ImageView设置图片的可见性,设置颜色的不同方法,设置图片指定大小
- 面试再谈struct和union大小问题
- 第3周项目4 顺序表应用问题(1)
- js页面滚动浮动层智能定位(jQuery)实例页面
- 第4周 项目3-单链表应用
- Servlet 3.0 新特性详解
- UITableViewCell中设置不同图片尺寸相同以及设置图片为圆形的方法
- 工作方法总结
- How can I get file extensions with JavaScript?
- 完整java开发中JDBC连接数据库代码和步骤
- SecureCRT 7.2.0 Mac版密码无法保存的解决办法(转载)
- [深入理解Java虚拟机]第三章 垃圾收集算法
- 第三周项目2——建设“顺序表”算法库
- Ubuntu 命令行基础,解压操作
- HTML <input type='file'> File Selection Event