1. 程式人生 > 其它 >iOS給UILabel設定內邊距

iOS給UILabel設定內邊距

    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:@"" attributes:@{ NSParagraphStyleAttributeName : style}];
     
    self.contentLbl.numberOfLines = 0;
    self.contentLbl.attributedText = attrText;

如果想偷個懶,那麼你出錢,我們出力.定製專屬於你的APP請諮詢我們:山東六牛網路科技有限公司