文本屬性Attributes
1.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設置文本扁平化
效果: