IOS UITextView 首行缩进

#pragma mark -UITextView的代理方法

-(void)textViewDidChange:(UITextView *)textView{

    //首行缩进

    NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStylealloc] init];

//    paragraphStyle.lineSpacing = 20;    //行间距

//    paragraphStyle.maximumLineHeight = 20;   /**最大行高*/

    paragraphStyle.firstLineHeadIndent =26.f;    /**首行缩进宽度*/

    paragraphStyle.alignment =NSTextAlignmentJustified;

    NSDictionary *attributes =@{

                                 NSFontAttributeName:[UIFontsystemFontOfSize:13],

                                 NSParagraphStyleAttributeName:paragraphStyle

                                 };

    textView.attributedText = [[NSAttributedStringalloc] initWithString:textView.textattributes:attributes];

}

你可能感兴趣的:(iOS)