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. for循环和while循环

    for循环和while循环 --道心 for循环 name1_list=['daoxin','wuxin','zhixin']for ele in name1_list: #找到"wuxin ...

  2. hadoop bug 笔记

    1.sqoop从mysql导入数据到hdfs的时候,总是在本地运行,而没有运行在集群上 sqoop  配置文件的问题 在 /usr/lib/sqoop/conf 目录下新增文件 sqoop-env.s ...

  3. vue 2.0 无法编译ES6语法

    # vue2.0 webpack 无法编译 ES6 语法 之前在使用 vue 1.x 时用 vue-loader@8.0.0 版本可以正常打包vue的代码,包括ES6语法也能正常转为ES5语法,但是当 ...

  4. js时间戳转换时间格式

    function getLocalTime(time){ if(time > 0){ var dateStr = new Date(time * 1000); var str = "& ...

  5. [MFC] 对话框菜单项Menu选中打勾(单选,多选)

    近期需要实现一个功能:MFC对话框中,一项菜单下有五个菜单项,改变菜单项选中状态,每次只能选择其中一个打勾.(单选) 然后在网上搜了下资料,稍微总结下,以防后面用到. 1.单选实现: CMenu* m ...

  6. linux xfce4普通用户 mount usb提示: Not authorized to perform operation

    问题:xfce4下,USB 硬盘能自动挂载并显示,但是普通用户操作时,提示:Not authorized to perform operation. 时间:20160928 os:gentoo + x ...

  7. linux shell脚本学习xargs命令使用详解

    作用是将参数列表转换成小块分段传递给其他命令,以避免参数列表过长的问题 xargs是给命令传递参数的一个过滤器,也是组合多个命令的一个工具.它把一个数据流分割为一些足够小的块,以方便过滤器和命令进行处 ...

  8. Python将列表中的string元素进行类型转换

    例如 将 a=['1','2.0','3L'] 转换为 a=[1,2.0,3L] 只需 map(eval,['1','2.0','3L']) 即可 eval(expression[, globals[ ...

  9. Playmaker 基础使用与案例操作

    首先是把下载好的插件导入Unity工程中. ▼导入完成后第一个动作就是检查下拉菜单里面是否已经增加了Playmaker的功能,如果在安装后没看到Playmaker的菜单,一般情况下直接点击菜单上的空白 ...

  10. MAC OS 快捷键一览

    OS X 键盘快捷键 键盘快捷键是通过按下键盘上的组合键来调用 OS X 功能的一种方式.了解有关常见 OS X 键盘快捷键的信息. 若要使用键盘快捷键,您可以同时按修饰键和字符键.例如,按下 Com ...