当文字过长时,需要让UILabel换行缩进,可采取以下方法,headIndent根据自己的需要设置
NSMutableParagraphStyle *style = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
style.headIndent = 17;
NSDictionary *attributes = @{ NSParagraphStyleAttributeName: style};
NSMutableAttributedString *richText = [[NSMutableAttributedString alloc] initWithString:@"1. 与xxxxxxx离得太远,建议将手机靠近床后重新搜索;\n2. xxxxxxxxxxxxx未通电,检查是否异常;\n3. xxxxxxxxxxxxxxx已被他人连接,让他人断开设备取消连接后,重新搜索;\n4. 手机蓝牙断开,重新开启蓝牙并搜索。" attributes:attributes];
//根据下标索引设置字体颜色
[richText addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(9, 2)];
//根据下标索引设置字体样式大小(式样只对字母有效)
[richText addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Arial-BoldItalicMT" size:30.0] range:NSMakeRange(0, 5)];
reasonContent.attributedText = richText;