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. Putty的注册表设置

    Putty是一款非常好用的远程管理Linux系统的工具,其主要具有以下几个优点:  完全免费;  在Windows 9x/NT/2000下运行的都非常好;  全面支持SSH1和SSH2:  绿色软件, ...

  2. C#23种开发模式,陆续完善中

    #region 单例模式 #region 线程非安全单例模式 public class Singleton1 { private Singleton1() { } private static Sin ...

  3. python2.x urllib2和urllib的使用

    1.最简单用法 urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,...) import urllib2 import ur ...

  4. Maven之(五)Maven仓库

    本地仓库 Maven一个很突出的功能就是jar包管理,一旦工程需要依赖哪些jar包,只需要在Maven的pom.xml配置一下,该jar包就会自动引入工程目录.初次听来会觉得很神奇,下面我们来探究一下 ...

  5. ngDialog 设置其宽度大小

    [ngdialog弹窗大小设置(angularjs)] 方法一:添加css样式属性 css: .ngdialog.ngdialog-theme-plain.custom-width-70 .ngdia ...

  6. XTU 1245 Hamiltonian Path

    $2016$长城信息杯中国大学生程序设计竞赛中南邀请赛$C$题 简单题. 注意题目中给出的数据范围:$1 \le ai < bi \le n$,说明这是一个有向无环图,并且哈密顿路一定是$1 \ ...

  7. 利用css来让一个div在页面中垂直居中的方法

    一.如何让一个div在页面中垂直居中(请至少列出三种) 1.距离页面窗口左边框和上边框的距离设置为50%,这个50%就是指页面窗口的宽度和高度的50%,最后将该DIV分别左移和上移,左移和上移的大小就 ...

  8. Git之”make sure you have the correct access…”

    git 命令在windows下无法使用pull.fetch.push等命令,提示 “please make sure you have the correct access and the repos ...

  9. redis整合spring

    最近公司项目有用到     所以找了一下实例.感觉很清晰.    完整项目路径http://www.cnblogs.com/dennisit/p/3614521.html看了一下应该没问题

  10. DUIlib使用Fastreport--报表简单使用

    fastreport是一个简单优秀的报表,fastreport更多是和delphi联合使用预览和打印数据的.我在开始使用duilib做项目时,打印和数据预览都是自己绘制的,这样不仅绘制麻烦费事费事,而 ...