iOS设置UILabel的行间距
2016-04-08 11:23
351 查看
NSString *textStr = @"iPhone规定:任何应用想访问麦克风,必须被授权麦克风服务。请进入“设置”->“隐私”->“麦克风”中打开QQ空间的麦克风服务。";
UIFont *textFont = [UIFont systemFontOfSize:14];
CGSize textSize = [textStr sizeWithFont:textFont
constrainedToSize:CGSizeMake(bounds.size.width - 40, QZONE_SCREEN_HEIGHT)];;
UILabel *openMicPrivilegeTipsLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 20, textSize.width, textSize.height)];
openMicPrivilegeTipsLabel.textColor = DefaultDescriptionText2ColorInDefaultTheme;
openMicPrivilegeTipsLabel.text = textStr;
openMicPrivilegeTipsLabel.backgroundColor = [UIColor clearColor];
openMicPrivilegeTipsLabel.textAlignment = UITextAlignmentLeft;
openMicPrivilegeTipsLabel.font = [UIFont systemFontOfSize:14];
openMicPrivilegeTipsLabel.numberOfLines = 0;
// 调整行间距
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:textStr];
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
[paragraphStyle setLineSpacing:6];
[attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [textStr length])];
openMicPrivilegeTipsLabel.attributedText = attributedString;
[_tipsBG addSubview:openMicPrivilegeTipsLabel];
[openMicPrivilegeTipsLabel sizeToFit];
UIFont *textFont = [UIFont systemFontOfSize:14];
CGSize textSize = [textStr sizeWithFont:textFont
constrainedToSize:CGSizeMake(bounds.size.width - 40, QZONE_SCREEN_HEIGHT)];;
UILabel *openMicPrivilegeTipsLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 20, textSize.width, textSize.height)];
openMicPrivilegeTipsLabel.textColor = DefaultDescriptionText2ColorInDefaultTheme;
openMicPrivilegeTipsLabel.text = textStr;
openMicPrivilegeTipsLabel.backgroundColor = [UIColor clearColor];
openMicPrivilegeTipsLabel.textAlignment = UITextAlignmentLeft;
openMicPrivilegeTipsLabel.font = [UIFont systemFontOfSize:14];
openMicPrivilegeTipsLabel.numberOfLines = 0;
// 调整行间距
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:textStr];
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
[paragraphStyle setLineSpacing:6];
[attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [textStr length])];
openMicPrivilegeTipsLabel.attributedText = attributedString;
[_tipsBG addSubview:openMicPrivilegeTipsLabel];
[openMicPrivilegeTipsLabel sizeToFit];
相关文章推荐
- LeetCode(36)- Implement Stack using Queues
- LeetCode(36)- Implement Stack using Queues
- LeetCode(36)- Implement Stack using Queues
- xcodebuild error: unable to rename temporary
- java之Continue解析
- dequeueReusableCellWithIdentifier和dequeueReusableCellWithIdentifier:forIndexPath的区别
- 使用Autolayout实现UITableView的Cell动态布局和高度动态改变
- iPhone/iPad/Android UI尺寸规范
- require和include的区别
- 2016.04.07,英语,《Vocabulary Builder》Unit 11
- iOS开发技巧(系列十二:UUID和UDID的区别)
- 标准模板库(STL)之 priority_queue 列传
- 黑暗料理一之修改UITableViewCell左滑删除按钮的样式和自定义
- LeetCode 128. Longest Consecutive Sequence
- ubuntu下打印unit64_t size_t uint32_t 类型
- xoyojank 的 UE4中的DynamicTexture数据更新
- [IOS 开发] 获取设备UUID
- UINavigationBar的视图层级关系
- iOS---[UIDevice identifierForVendor]慎用!
- Qt 示例学习--2. calendar quick controls