ios根据文本自适应 然后 搭建类似如下效果
UIView * headView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.tbSecond.size.width, 0)];
headView.backgroundColor = [UIColor whiteColor];
UIView * view = [[UIView alloc]initWithFrame:CGRectMake(30, 40, self.tbSecond.bounds.size.width - 90, 0)];
view.layer.borderWidth = 1;
view.layer.borderColor = [UIColor orangeColor].CGColor;
view.backgroundColor = [UIColor whiteColor];
UILabel * contentLabel = [[UILabel alloc]initWithFrame:CGRectMake(15, 30, self.tbSecond.bounds.size.width - 120, 0)];
contentLabel.numberOfLines = 0;
contentLabel.lineBreakMode = NSLineBreakByCharWrapping;
contentLabel.font = [UIFont systemFontOfSize:12];
contentLabel.textColor = [UIColor redColor];
contentLabel.text = visitModel.record?visitModel.record:@"";
CGSize textSize1 = [visitModel.record boundingRectWithSize:view.bounds.size options:NSStringDrawingUsesLineFragmentOrigin |NSStringDrawingTruncatesLastVisibleLine attributes:nil context:nil].size;
NSLog(@"%f",textSize1.height);
CGRect rect = contentLabel.frame;
rect.size.height = textSize1.height+30;
contentLabel.frame = rect;
[view addSubview:contentLabel];
view.height = rect.size.height + 45;
[headView addSubview:view];
headView.height = rect.size.height + 105;
UIView * showView = [[UIView alloc]initWithFrame:CGRectMake(view.center.x-40, 20, 120, 40)];
showView.backgroundColor = [UIColor whiteColor];
UIImageView * headIV = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 40, 40)];
headIV.image = [UIImage imageNamed:@"home_circle_icon"];
[showView addSubview:headIV];
UIImageView * headIMV = [[UIImageView alloc]initWithFrame:CGRectMake(10, 10, 30, 30)];
headIMV.layer.cornerRadius = 15;
headIMV.layer.masksToBounds = YES;
[headIMV sd_setImageWithURL:[NSURL URLWithString:visitModel.headPicUrl] placeholderImage:[UIImage imageNamed:@"home_headpic"]];
[showView addSubview:headIMV];
UIImageView * lianxiwo = [[UIImageView alloc]initWithFrame:CGRectMake(50, 7, 25, 25)];
lianxiwo.image = [UIImage imageNamed:@"lianxiwo"];
[showView addSubview:lianxiwo];
UIImageView * dianhua = [[UIImageView alloc]initWithFrame:CGRectMake(90, 7, 25, 25)];
dianhua.image = [UIImage imageNamed:@"dianhua"];
[showView addSubview:dianhua];
UIButton * lianxiwoBtn = [[UIButton alloc]initWithFrame:CGRectMake(45, 2, 35, 35)];
[lianxiwoBtn addTarget:self action:@selector(lianxiwoBtnClick) forControlEvents:UIControlEventTouchUpInside];
[showView addSubview:lianxiwoBtn];
UIButton * dianhuaBtn = [[UIButton alloc]initWithFrame:CGRectMake(80, 2, 35, 35)];
[dianhuaBtn addTarget:self action:@selector(dianhuaBtnClick) forControlEvents:UIControlEventTouchUpInside];
[showView addSubview:dianhuaBtn];
[headView addSubview:showView];
UILabel * companyLabel = [[UILabel alloc]initWithFrame:CGRectMake(view.center.x-60, headView.height-30, 120, 20)];
companyLabel.backgroundColor = [UIColor whiteColor];
companyLabel.textAlignment = NSTextAlignmentCenter;
companyLabel.font = [UIFont systemFontOfSize:14];
companyLabel.textColor = [UIColor orangeColor];
companyLabel.text = visitModel.userName?visitModel.userName:@"";
[headView addSubview:companyLabel];
UILabel * timeLabel = [[UILabel alloc]initWithFrame:CGRectMake(self.tbSecond.bounds.size.width-60, headView.height-35, 60, 20)];
timeLabel.textAlignment = NSTextAlignmentCenter;
timeLabel.font = [UIFont systemFontOfSize:12];
timeLabel.textColor = mRGBToColor(0x999999);
timeLabel.text = visitModel.time?visitModel.time:@"";
[headView addSubview:timeLabel];
[self.view addSubview:headView];
也可以 把上述的 写成 tableView的headView
结合tableView实现如下效果
ios根据文本自适应 然后 搭建类似如下效果的更多相关文章
- iOS UILabel UITextView自适应文本,或文本大小自适应
//UILabel自适应文本的高度 UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(, , , )]; label.numberOf ...
- ios之UILabel实现文本自适应方法
UILabel实现文本自适应方法(ios7) - (void)initUserInterface { UILabel *label = [[UILabel alloc]init]; label.num ...
- iOS - 富文本AttributedString
最近项目中用到了图文混排,所以就研究了一下iOS中的富文本,打算把研究的结果分享一下,也是对自己学习的一个总结. 在iOS中或者Mac OS X中怎样才能将一个字符串绘制到屏幕上呢? ...
- iOS富文本组件的实现—DTCoreText源码解析 数据篇
本文转载 http://blog.cnbang.net/tech/2630/ DTCoreText是个开源的iOS富文本组件,它可以解析HTML与CSS最终用CoreText绘制出来,通常用于在一些需 ...
- iOS 从0到1搭建高可用App框架
iOS 从0到1搭建高可用App框架 最近在搭建新项目的iOS框架,一直在思考如何才能搭建出高可用App框架,能否避免后期因为代码质量问题的重构.以前接手过许多“烂代码”,架构松散,底层混乱,缺少规范 ...
- iOS 检测文本中的 URL、电话号码等信息
iOS 检测文本中的 URL.电话号码等信息 要检测文本中的 URL.电话号码等,除了用正则表达式,还可以用 NSDataDetector. 用 NSTextCheckingResult.Checki ...
- appium ios真机自动化环境搭建&运行(送源码)
appium ios真机自动化环境搭建&运行(送源码) 原创: f i n 测试开发社区 6天前 Appium测试环境的搭建相对比较烦琐,不少初学者在此走过不少弯路 首先是熟悉Mac的使用 ...
- appium ios真机自动化环境搭建&运行(送源码)
appium ios真机自动化环境搭建&运行(送源码) 原创: f i n 测试开发社区 6天前 Appium测试环境的搭建相对比较烦琐,不少初学者在此走过不少弯路 首先是熟悉Mac的使用 ...
- 实现js的类似alert效果的函数
这个简单的类似alert的函数,效果还行,至于css样式,那没的说了,笔者确实尽力了,如果读者觉得太烂,你可以随便改函数的样式的,反正,笔者觉得还可以,呵呵. <!DOCTYPE html PU ...
随机推荐
- bzoj1180,2843
1180: [CROATIAN2009]OTOCI Time Limit: 50 Sec Memory Limit: 162 MBSubmit: 967 Solved: 597[Submit][S ...
- 图像预处理(Evision)
Convolution //采用线性过滤Linear combination of neighboring pixels using a convolution kernel−Pre-defined ...
- C#Dictionary集合的使用
题目:输入一串字符串字母,比如:Welcome to China,比较每个字母出现的次数,不区分大小写. 解决这道题的方法很多.可能一百个人有一百个思路.当时第一眼看到这个题我的思路是:先将接受的一串 ...
- 安装hadoop-eclipse-plugin插件报错解决办法
安装myecplise的hadoop-eclipse-plugin-2.2.0插件的时候, 把插件放到这个文件夹里 打开myeclipse windows-->preferences 点击 H ...
- 修改/etc/resolv.conf又恢复到原来的状态?[转]
新装一台机器环境为服务器主板,双网卡,系统为CentOS5.4 ,eth0为内网ip,eth1为公网ip.但是由于在本地测试,设置的内网ip,域名服务器同样使用的是上海本地的域名解析,没有问题,可以上 ...
- UVAlive 6833 Miscalculation 字符串处理
去年省选的题 因为卡了这道题再加上队友占机时 省选第一天华丽爆零了 用事实证明了1+1+1<1的事实 毕竟下半年单挑了东北赛名额 省赛打不出来名额就真的就不怪我了(摔 现在有拿出来做 长个记性 ...
- 记JavaScript的入门学习(二)
2016年11月25号,利用上午时间学习了JavaScript的数据类型和变量,下午就该去图书馆泡书了. 看完变量的本章节,发现我可能不能一天结束,那我就利用上午和晚上九点回来的时间完成吧.把心态调整 ...
- android studio 将library导出为jar 亲测成功
本人使用的是helloChart这个开源项目,其主要用于图表,来自git 地址为:https://github.com/lecho/hellocharts-android 下载命令为 git clon ...
- 照片处理软件(iSee图片专家) 3.930 中文免费版
软件名称: 照片处理软件(iSee图片专家) 软件语言: 简体中文 授权方式: 免费软件 运行环境: Win 32位/64位 软件大小: 13.5MB 图片预览: 软件简介: iSee图片专家,免费一 ...
- CUDA开发存储器运用(包括存储器之间的转存)
主机端内存(host memory) 主机端叶锁定内存(pinned memory) 显存 寄存器(register) 局部存储器(local memory) 共享存储器(shared memory) ...