iOS学习-如何缩进UILABEL的第二行

当文字过长时,需要让UILabel换行缩进,可采取以下方法,headIndent根据自己的需要设置

    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;

猜你喜欢

转载自blog.csdn.net/qq_43441647/article/details/131962450