iOS learning - how to indent the second line of UILABEL

When the text is too long, you need to make UILabel wrap and indent, you can take the following method, set headIndent according to your needs

    NSMutableParagraphStyle *style = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
    style.headIndent = 17;
    NSDictionary *attributes = @{ NSParagraphStyleAttributeName: style};
    NSAttributedString *richText = [[NSAttributedString alloc] initWithString:@"1.  与xxxxxxx离得太远,建议将手机靠近床后重新搜索;\n2. xxxxxxxxxxxxx未通电,检查是否异常;\n3. xxxxxxxxxxxxxxx已被他人连接,让他人断开设备取消连接后,重新搜索;\n4. 手机蓝牙断开,重新开启蓝牙并搜索。" attributes:attributes];
    reasonContent.attributedText = richText;

Guess you like

Origin blog.csdn.net/qq_43441647/article/details/131962450