Luc*_*ira 3 line-breaks nsstring ios
我有NSString这样的
NSString *string = @"textTextTextTextText<br>textTextTextText<br>TextTextText"
我想将此设置NSString为我的文本,在字符串UICell上
找到的每个标记上都有一个新行.我怎么能这样做?
我试过这个,没有成功:
cell.textLabel.text = [[text componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]] componentsJoinedByString:@"<br>"];
Ash*_*lls 13
怎么样:
string = [string stringByReplacingOccurrencesOfString: @"<br>" withString: @"\n"]
Run Code Online (Sandbox Code Playgroud)
或者,如果你使用Swift Strings
var string = "textTextTextTextText<br>textTextTextText<br>TextTextText"
string = Array(string).reduce("") {$0 + ($1 == "<br>" ? "\n" : $1)}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7966 次 |
| 最近记录: |