UILabel和UITextView自适应高度
来源:互联网 发布:魔域答题软件 编辑:程序博客网 时间:2024/05/22 08:17
//UILabel自动换行,自适应高度
UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero];
[label setBackgroundColor:[UIColor clearColor]];
[label setFont:[UIFont systemFontOfSize:14]];
[label setLineBreakMode:UILineBreakModeWordWrap];
[label setNumberOfLines:0];
[self.view addSubview:label];
NSString *str = @"那些年错过的大雨 那些年错过的爱情 好想拥抱你 拥抱错过的勇气 曾经想征服全世界 到最后回首才发现 这世界滴滴点点全部都是你 那些年错过的大雨 那些年错过的爱情 好想告诉你 告诉你我没有忘记 那天晚上满天星星 平行时空下的约定 再一次相遇我会紧紧抱着你 紧紧抱着你";
CGSize size = [str sizeWithFont:[UIFont systemFontOfSize:14] constrainedToSize:CGSizeMake(320,500) lineBreakMode:UILineBreakModeWordWrap];
[label setText:str];
[label setFrame:CGRectMake(0.0f, 20.0f, size.width, size.height)];
[label release];
//UITextView自动换行,自适应高度
UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(0, 150, 320, 240)];
textView.backgroundColor = [UIColor clearColor];
textView.text = str;
textView.scrollEnabled = YES;
textView.font = [UIFont systemFontOfSize:14];
textView.userInteractionEnabled = NO;
textView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero];
[label setBackgroundColor:[UIColor clearColor]];
[label setFont:[UIFont systemFontOfSize:14]];
[label setLineBreakMode:UILineBreakModeWordWrap];
[label setNumberOfLines:0];
[self.view addSubview:label];
NSString *str = @"那些年错过的大雨 那些年错过的爱情 好想拥抱你 拥抱错过的勇气 曾经想征服全世界 到最后回首才发现 这世界滴滴点点全部都是你 那些年错过的大雨 那些年错过的爱情 好想告诉你 告诉你我没有忘记 那天晚上满天星星 平行时空下的约定 再一次相遇我会紧紧抱着你 紧紧抱着你";
CGSize size = [str sizeWithFont:[UIFont systemFontOfSize:14] constrainedToSize:CGSizeMake(320,500) lineBreakMode:UILineBreakModeWordWrap];
[label setText:str];
[label setFrame:CGRectMake(0.0f, 20.0f, size.width, size.height)];
[label release];
//UITextView自动换行,自适应高度
UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(0, 150, 320, 240)];
textView.backgroundColor = [UIColor clearColor];
textView.text = str;
textView.scrollEnabled = YES;
textView.font = [UIFont systemFontOfSize:14];
textView.userInteractionEnabled = NO;
textView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
[self.view addSubview:textView];
- UILabel和UITextView自适应高度
- UILabel和UITextView自适应高度
- UILabel和UITextView自适应高度
- UILabel, UITextView 高度自适应
- UILabel, UITextView 高度自适应
- UILabel、UITextView自适应得到高度
- UILabel、UITextView自适应得到高度
- UILabel、UITextView自适应得到高度
- UILabel、UITextView自适应得到高度
- UILabel、UITextView自适应得到高度
- iOS开发笔记--UILabel和UITextView自适应文本高度代码
- iOS开发笔记--UILabel和UITextView自适应文本高度代码
- 实现UILabel高度和宽度的自适应和UITextView的高度自适应
- 实现UILabel高度和宽度的自适应和UITextView的高度自适应
- uilabel 和uitextview 自适应大小
- UiTextView 和UILabel 高度计算
- UIlabel自适应高度和UITableViewCell自适应高度
- UILabel自适应宽度和高度
- linux vi命令
- layoutSubviews总结
- IOS 开发中对url中的参数进行URLEncode编码的实现
- [cocos2d-x]学习demo一些未理解的知识点
- Linux下SSH远程文件传输命令scp
- UILabel和UITextView自适应高度
- 初窥虚函数联编问题
- js正则函数match、exec、test、search、replace、split使用介绍集合
- MySQL左连接、右连接
- boost库在工作(32)网络服务端之二
- 只需三步:在Windows 7上卸载IE10
- 昂达v811v1 刷4.22d
- MySQL数据库datetime类型不能为空字符串的问题
- MP4/MOV/3GP文件的“ftyp”