码迷,mamicode.com
首页 > 其他好文 > 详细

2016-02-22 类似qq对话的文字嵌入在图片中

时间:2016-02-23 12:47:18      阅读:145      评论:0      收藏:0      [点我收藏+]

标签:

//gzz0223
//计算文本的大小
NSString *srring=[NSString stringWithFormat:@"%@",[dataDic objectForKey:@"content"]];

NSUserDefaults * userdefaults =USERDEFAULT;
[userdefaults setValue:srring forKey:@"zixunxiangqing"];
[userdefaults synchronize];
CGSize size111 = [srring boundingRectWithSize:CGSizeMake(250, 1000) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:15.0]} context:nil].size;


// 气泡素材
UIImage* leftImage = [UIImage imageNamed:@"ReceiverTextNodeBkg.png"];
leftImage = [leftImage stretchableImageWithLeftCapWidth:30 topCapHeight:35];
//
CGFloat xx=85;
CGFloat yy=20;
CGFloat ww=ConentViewWidth-90;

CGFloat hh=size111.height+20;

注:不行的话 改变红色字体,实在不行的话  试试绿色
UIImageView *coverImage = [[UIImageView alloc] initWithFrame:CGRectMake(xx,yy , ww, hh)];
coverImage.image = leftImage;
[self.view addSubview:coverImage];
UILabel *l=[[ UILabel alloc]initWithFrame:CGRectMake(10+8, 80, ConentViewWidth- 20, 100)];
l.frame =CGRectMake(85+13, 20+8,ConentViewWidth-105, size111.height);
l.text=srring;
l.numberOfLines = 0;
l.lineBreakMode = NSLineBreakByWordWrapping;
[self.view addSubview:l];

2016-02-22 类似qq对话的文字嵌入在图片中

标签:

原文地址:http://www.cnblogs.com/gzz2016/p/5209333.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!