iOS-段落NSMutableParagraphStyle

2019-05-24  本文已影响0人  fly大梦想家
   NSMutableAttributedString * attributedString = [[NSMutableAttributedString alloc]initWithString:_content];
    [attributedString addAttribute:NSForegroundColorAttributeName value:[GOVCommon colorForKey:@"noticeViewMainColor"] range:NSMakeRange(0, _content.length)];
    NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init];
    paragraphStyle.maximumLineHeight = LAYOUT_SIZESCALE_PORTRAIT(12, 6).height;  // 最大行间距
    paragraphStyle.minimumLineHeight = LAYOUT_SIZESCALE_PORTRAIT(12, 6).height;  // 最小行间距
    paragraphStyle.paragraphSpacingBefore = LAYOUT_SIZESCALE_PORTRAIT(12, 14).height; // 段间距
    paragraphStyle.firstLineHeadIndent = LAYOUT_SIZESCALE_PORTRAIT(40, 40).width;  // 段落第一行缩进
    paragraphStyle.lineSpacing = 20; // 行间距
    paragraphStyle.headIndent = 50; // 头缩进
    paragraphStyle.lineBreakMode = NSLineBreakByWordWrapping;
    [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [_content length])];

上一篇下一篇

猜你喜欢

热点阅读