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根据文本自适应 然后 搭建类似如下效果的更多相关文章

  1. iOS UILabel UITextView自适应文本,或文本大小自适应

    //UILabel自适应文本的高度 UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(, , , )]; label.numberOf ...

  2. ios之UILabel实现文本自适应方法

    UILabel实现文本自适应方法(ios7) - (void)initUserInterface { UILabel *label = [[UILabel alloc]init]; label.num ...

  3. iOS - 富文本AttributedString

    最近项目中用到了图文混排,所以就研究了一下iOS中的富文本,打算把研究的结果分享一下,也是对自己学习的一个总结. 在iOS中或者Mac OS X中怎样才能将一个字符串绘制到屏幕上呢?         ...

  4. iOS富文本组件的实现—DTCoreText源码解析 数据篇

    本文转载 http://blog.cnbang.net/tech/2630/ DTCoreText是个开源的iOS富文本组件,它可以解析HTML与CSS最终用CoreText绘制出来,通常用于在一些需 ...

  5. iOS 从0到1搭建高可用App框架

    iOS 从0到1搭建高可用App框架 最近在搭建新项目的iOS框架,一直在思考如何才能搭建出高可用App框架,能否避免后期因为代码质量问题的重构.以前接手过许多“烂代码”,架构松散,底层混乱,缺少规范 ...

  6. iOS 检测文本中的 URL、电话号码等信息

    iOS 检测文本中的 URL.电话号码等信息 要检测文本中的 URL.电话号码等,除了用正则表达式,还可以用 NSDataDetector. 用 NSTextCheckingResult.Checki ...

  7. appium ios真机自动化环境搭建&运行(送源码)

    appium ios真机自动化环境搭建&运行(送源码) 原创: f i n  测试开发社区  6天前 Appium测试环境的搭建相对比较烦琐,不少初学者在此走过不少弯路 首先是熟悉Mac的使用 ...

  8. appium ios真机自动化环境搭建&运行(送源码)

    appium ios真机自动化环境搭建&运行(送源码) 原创: f i n  测试开发社区  6天前 Appium测试环境的搭建相对比较烦琐,不少初学者在此走过不少弯路 首先是熟悉Mac的使用 ...

  9. 实现js的类似alert效果的函数

    这个简单的类似alert的函数,效果还行,至于css样式,那没的说了,笔者确实尽力了,如果读者觉得太烂,你可以随便改函数的样式的,反正,笔者觉得还可以,呵呵. <!DOCTYPE html PU ...

随机推荐

  1. C#Redis字符串

    上周六通宵打牌周日白天只睡3小时累成狗,从今天起以后不能玩太大的了,小赌怡情大赌伤身,和同事朋友有空玩玩还是好的.今天公司外面马路上有人挂灯笼时死了一个人,哎,快过年了悲剧又发生了,真是生命是脆弱的. ...

  2. Nexpose

    下载: https://www.rapid7.com/products/nexpose/nexpose-enterprise-trial-thank-you.jsp注册: https://www.ra ...

  3. hdu 5996 dingyeye loves stone(博弈)

    题目链接:hdu 5996 dingyeye loves stone 题意: 给你一棵树,树的每一个节点有a[i]个石子,每个人可以将这个节点的石子移向它的父亲,如果没有合法操作,那么就算输,现在给你 ...

  4. linux 学习-软件的安装

    Linux软件的安装rpm -ivh安装软件全名 -i install 安装 -v verbose 显示详细信息 -h hash 显示进度 --nodeps 不检测依赖性(不推荐使用) rpm -U ...

  5. 打印java堆栈信息

    使用如下命令: kill -3 {pid} 可以打印指定线程的堆栈信息到tomcat的catalina.out日志中.在性能测试过程中,可以观察响应时间的曲线,如果突然出现波峰则抓取当前时间点tomc ...

  6. Java 不使用科学计数法表示数据设置

    java.text.NumberFormat nf = java.text.NumberFormat.getInstance(); nf.setGroupingUsed(false); nf.form ...

  7. python3数据结构

    列表 list.append(x) 把一个元素添加到列表的结尾,相当于a[len(a):]=[x] list.extend(L) 将一个给定列表中的所有元素都添加到另一个列表中,相当于a[(len): ...

  8. js的特殊运算符

    1)三元条件运算符: c是一个布尔值,当c为true的时候,取冒号左边a的值,否取冒号右边的b的值: 2)逗号运算符: 值从左到右依次计算,取最右边的,例如例子里的val,会取最右边的值3: 特殊运算 ...

  9. 2、表单form

    只要使用input,就用form,使用方法是在所有的input之外加一个总的form双标签 切记给每个input都加name,提交表单时同时会提交name属性 input可以做的事:文本框.密码框.单 ...

  10. VB调用WebService(SOA2.0接口)(直接Post方式)并解析返回的XML

    SOA 2.0接口 Function GetDepartmentCode(reqDeptCode) Dim soaRequestXML : soaRequestXML = "" D ...