作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用行间距为 1.25 的多行 NSAttributedString。
NSMutableParagraphStyle *bodyFormat = [[NSMutableParagraphStyle alloc] init];
bodyFormat.alignment = NSTextAlignmentLeft;
//[bodyFormat setLineSpacing:5];
[bodyFormat setLineBreakMode:NSLineBreakByWordWrapping];
//[bodyFormat setMaximumLineHeight:5];
[bodyFormat setLineHeightMultiple:1.25];
NSMutableAttributedString *desc = [[NSMutableAttributedString alloc] initWithString:@"So why to use Lorem Ipsum and why placeholder text is necessary? Naturally, page designs that are made for text documents must contain some text rather than placeholder dots or something else. Howevr, should they contain a proper English words and sentenses almost every reader will deliberately try to interpret it eventually missing the design itself"];
[desc addAttribute:NSParagraphStyleAttributeName value:bodyFormat range:NSMakeRange(0, desc.length)];
UILabel *description = [[UILabel alloc] initWithFrame:CGRectMake(0,
20,
300,
1000)];
description.lineBreakMode = NSLineBreakByWordWrapping;
[description setAttributedText:desc];
[self.view addSubview:description];
这设法产生单行,换行符无效。
我做错了什么?
最佳答案
[bodyFormat setLineSpacing:5];
打破这种行为。
同时设置
description.numberOfLines = 0;
帮助...(描述是 UILabel)
关于ios - NSMutableParagraphStyle 和 NSAttributedString 无法 wordrap,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21962650/
我正在尝试使用行间距为 1.25 的多行 NSAttributedString。 NSMutableParagraphStyle *bodyFormat = [[NSMutableParagraphS
我是一名优秀的程序员,十分优秀!