NSMutableParagraphStyle /NSParagraphStyle,nsparagraphstyle詳解

來源:互聯網
上載者:User

NSMutableParagraphStyle /NSParagraphStyle,nsparagraphstyle詳解

    1. //   NSParagraphStyleAttributeName 段落的風格(設定首行,行間距,對齊什麼的)看自己需要什麼屬性,寫什麼  
    2.     NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];  
    3.     paragraphStyle.lineSpacing = 10;// 字型的行間距  
    4.     paragraphStyle.firstLineHeadIndent = 20.0f;//首行縮排  
    5.     paragraphStyle.alignment = NSTextAlignmentJustified;//(左右對齊的)文本對齊:(左,中,右,左右對齊,自然)  
    6.     paragraphStyle.lineBreakMode = NSLineBreakByTruncatingTail;//結尾部分的內容以……方式省略 ( "...wxyz" ,"abcd..." ,"ab...yz")  
    7.     paragraphStyle.headIndent = 20;//整體縮排(首行除外)  
    8.     paragraphStyle.tailIndent = 20;//  
    9.     paragraphStyle.minimumLineHeight = 10;//最低行高  
    10.     paragraphStyle.maximumLineHeight = 20;//最大行高  
    11.     paragraphStyle.paragraphSpacing = 15;//段與段之間的間距  
    12.     paragraphStyle.paragraphSpacingBefore = 22.0f;// 段首行空白空間 /* Distance between the bottom of the previous paragraph (or the end of its paragraphSpacing, if any) and the top of this paragraph. */  
    13.     paragraphStyle.baseWritingDirection = NSWritingDirectionLeftToRight;//從左至右的書寫方向(一共️三種)  
    14.     paragraphStyle.lineHeightMultiple = 15;/* Natural line height is multiplied by this factor (if positive) before being constrained by minimum and maximum line height. */  
    15.     paragraphStyle.hyphenationFactor = 1;//連字屬性 在iOS,唯一支援的值分別為0和1  
    16.   
    17.   
    18.   
    19.   
    20.   
    21.   
    22.   
    23. /* 
    24.      NSFontAttributeName 字型大小 
    25.      NSParagraphStyleAttributeName 段落的風格(設定首行,行間距,對齊什麼的) 
    26.      NSKernAttributeName 字間距 
    27.      */  
    28.     NSDictionary *attributes = @{  
    29.                                  NSFontAttributeName:[UIFont systemFontOfSize:15],  
    30.                                  NSParagraphStyleAttributeName:paragraphStyle,  
    31.                                  NSKernAttributeName:@(10),  
    32.                                                                 
    33.                                  };  
    34.     textView.attributedText = [[NSAttributedString alloc] initWithString:textView.text attributes:attributes]; 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.