iOS —— Attributes文字的操作,TextFiel框內文字顏色大小等改變

來源:互聯網
上載者:User

iOS —— Attributes文字的操作,TextFiel框內文字顏色大小等改變
文字屬性Attributes1.NSKernAttributeName: @10 調整字句 kerning 字句調整2.NSFontAttributeName : [UIFont systemFontOfSize:_fontSize] 設定字型3.NSForegroundColorAttributeName :[UIColor redColor] 設定文字顏色4.NSParagraphStyleAttributeName : paragraph 設定段落樣式5.NSMutableParagraphStyle *paragraph = [[NSMutableParagraphStyle alloc] init];paragraph.alignment = NSTextAlignmentCenter;6.NSBackgroundColorAttributeName: [UIColor blackColor] 設定背景顏色7.NSStrokeColorAttributeName設定文字描邊顏色,需要和NSStrokeWidthAttributeName設定描邊寬度,這樣就能使文字空心.

NSStrokeWidthAttributeName這個屬性所對應的值是一個 NSNumber 對象(小數)。該值改變描邊寬度(相對於字型size 的百分比)。預設為 0,即不改變。正數只改變描邊寬度。負數同時改變文字的描邊和填充寬度。例如,對於常見的空心字,這個值通常為3.0。

同時設定了空心的兩個屬性,並且NSStrokeWidthAttributeName屬性設定為整數,文字前景色彩就無效果了

效果:

效果:

8. NSStrikethroughStyleAttributeName 添加刪除線,strikethrough刪除線

效果:

9. NSUnderlineStyleAttributeName 添加底線

效果:

10. NSShadowAttributeName 設定陰影,單獨設定不好使,必須和其他屬性搭配才好使。

和這三個任一個都好使,NSVerticalGlyphFormAttributeName,NSObliquenessAttributeName,NSExpansionAttributeName

11.NSVerticalGlyphFormAttributeName

該屬性所對應的值是一個 NSNumber 對象(整數)。0 表示橫排文本。1 表示豎排文本。在 iOS 中,總是使用橫排文本,0 以外的值都未定義。

效果:

12. NSObliquenessAttributeName設定字型傾斜。Skew 斜

效果:

13. NSExpansionAttributeName設定文本扁平化

效果:

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.