UILabel设定行间距方法
2015-07-09 22:09
573 查看
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];
相关文章推荐
- UILabel设定行间距方法
- [UGUI]UGUI使用图片文字(Custom Font)
- [UGUI]深入理解Canvas Scaler
- UILabel使用的小技巧
- Android UI高级交互设计Demo
- QPushButton 自定义下拉菜单,不使用setMuen()接口
- 《编程导论(Java)·附录A 使用BlueJ》
- Easyui 小脚本
- MVC4 +EasyUI Tabs 使用
- MVC+EasyUI 菜单导航的实现
- UINavigationController
- 学习easyui疑惑(四)
- MVC4 +EasyUI 使用TreeGrid 方法
- 16-UIViewController 手动控制旋转
- 15-UIViewController 与 状态栏模式设定
- 14-UI控件练习示例QQ音乐
- 13-常见UI控件之 UIPageControl分页
- 12-常用UI控件之 UISwitch开关
- 解决OC 字典根据Value找Key 重复和不重复的两种情况
- 11-常用UI控件之 UIProgressView 进度指示器