attributes最常用的设置就是设置颜色和字体大小,其他效果不是很常用但是也总结一下
NSDictionary *attributesDictionary = [NSDictionary dictionary];
[attributesDictionary setValue:[UIFont systemFontOfSize:18.0] forKey:NSFontAttributeName];//设置字体大小
[attributesDictionary setValue:[UIColor purpleColor] forKey:NSForegroundColorAttributeName];//设置文字颜色
[attributesDictionary setValue:[UIColor whiteColor] forKey:NSBackgroundColorAttributeName];//设置背景色
[attributesDictionary setValue:@5 forKey:NSKernAttributeName];//调整间距
[attributesDictionary setValue:@(NSUnderlineStyleSingle ) forKey:NSUnderlineStyleAttributeName];//设置下划线(NSUnderlineStyleSingle :单行下划线 NSUnderlineStyleDouble:两行下划线 )
[attributesDictionary setValue:@(NSUnderlineStyleSingle) forKey:NSStrikethroughStyleAttributeName];//添加删除线(value值和下划线用法相同)
[attributesDictionary setValue:@0 forKey:NSVerticalGlyphFormAttributeName];//设置横排还是竖排显示,0代表横排显示
[attributesDictionary setValue:@0.5 forKey:NSObliquenessAttributeName];//设置字体倾斜度
[attributesDictionary setValue:@1 forKey:NSExpansionAttributeName];//设置扁平化
//设置阴影:NSShadowAttributeName
//设置段落样式:NSParagraphStyleAttributeName(数值:nit];
// paragraph.alignment = NSTextAlignmentCenter;)