UILabel ,UITextView设置行间距
2016-01-08 11:55
597 查看
- (UITextView *)instructionTextView{
if (!_instructionTextView) {
_instructionTextView = [[UITextView alloc] init];
_instructionTextView.layer.borderWidth = 1.0f;
_instructionTextView.layer.borderColor = HexRGB(0xe6e6e6).CGColor;
_instructionTextView.backgroundColor = HexRGB(0xf9f9f9);
_instructionTextView.font = [UIFont systemFontOfSize:15];
_instructionTextView.delegate = self;
_instructionTextView.textColor = HexRGB(0x676767);
_instructionTextView.textContainerInset = UIEdgeInsetsMake(10, 5, 10, 5);
_instructionTextView.autoresizesSubviews = NO;
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
paragraphStyle.lineSpacing = 7;//
字体的行间距
NSDictionary *attributes = @{
NSFontAttributeName:[UIFont systemFontOfSize:14],
NSParagraphStyleAttributeName:paragraphStyle
};
_instructionTextView.attributedText = [[NSAttributedString alloc] initWithString:@" " attributes:attributes];
}
return _instructionTextView;
}
获取内容的size大小:
self.achievementSize = [self.achievementTextView.text boundingRectWithSize:CGSizeMake(wei,2000.0f) options:NSStringDrawingUsesLineFragmentOrigin attributes:attributes context:nil].size;
if (!_instructionTextView) {
_instructionTextView = [[UITextView alloc] init];
_instructionTextView.layer.borderWidth = 1.0f;
_instructionTextView.layer.borderColor = HexRGB(0xe6e6e6).CGColor;
_instructionTextView.backgroundColor = HexRGB(0xf9f9f9);
_instructionTextView.font = [UIFont systemFontOfSize:15];
_instructionTextView.delegate = self;
_instructionTextView.textColor = HexRGB(0x676767);
_instructionTextView.textContainerInset = UIEdgeInsetsMake(10, 5, 10, 5);
_instructionTextView.autoresizesSubviews = NO;
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
paragraphStyle.lineSpacing = 7;//
字体的行间距
NSDictionary *attributes = @{
NSFontAttributeName:[UIFont systemFontOfSize:14],
NSParagraphStyleAttributeName:paragraphStyle
};
_instructionTextView.attributedText = [[NSAttributedString alloc] initWithString:@" " attributes:attributes];
}
return _instructionTextView;
}
获取内容的size大小:
self.achievementSize = [self.achievementTextView.text boundingRectWithSize:CGSizeMake(wei,2000.0f) options:NSStringDrawingUsesLineFragmentOrigin attributes:attributes context:nil].size;
相关文章推荐
- 程序员面试问题2:矩阵区域和 Programming Interview Questions 2: Matrix Region Sum
- (java)Range Sum Query - Immutable
- Android TextView 跑马灯效果 android:ellipsize="marquee"
- Win7 Ubuntu双系统,删除并格式化Ubuntu分区后,启动出现grub rescue的解决方法
- uinput的使用
- UITextField文本框详解
- 1.2.0 Quickstart: "Hello World"(快速开始:“你好世界!”)
- 关于CC2540/2541编译Performing Post-Build Action卡住的问题
- iOS UISearchBar 和 UISearchDisplayController的使用
- ios UITableView 滑动 headerView footerView 跟随问题
- UIImage图片处理
- 输出字典中的key和 value
- 年结Close Process的两支Request
- mysql导入报错Variable 'sql_notes' can't be set to the value of 'NULL'
- 显示和隐藏easyui combobox
- 响应式web设计之CSS3 Media Queries
- EasyUI验证扩展
- Sql server 数据库 int 和guid 两者的比较
- UILabel关于支持HTML格式 自动换行 行间距的封装
- UITextView 四周间距