利用 NSMutableParagraphStyle 实现文字缩进

NSMutableParagraphStyle *style = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
// 对齐方式
style.alignment = NSTextAlignmentJustified;
// 首行缩进
style.firstLineHeadIndent = 10.0f;
// 头部缩进
style.headIndent = 10.0f;
// 尾部缩进
style.tailIndent = -10.0f;
NSAttributedString *attrText = [[NSAttributedString alloc] initWithString:title attributes:@{ NSParagraphStyleAttributeName : style}];
UILabel *label = [[UILabel alloc] initWithFrame:someFrame];
label.numberOfLines = 0;
label.attributedText = attrText;

相关文章:

  • 2022-12-23
  • 2021-12-15
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-22
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-01-08
  • 2022-12-23
  • 2022-12-23
  • 2021-09-03
  • 2022-12-23
相关资源
相似解决方案