Attributes的NSDctionary设置

来源:互联网 发布:jquery监听数组长度 编辑:程序博客网 时间:2024/06/05 04:37

attributes最常用的设置就是设置颜色和字体大小,其他效果不是很常用但是也总结一下

  NSDictionary *attributesDictionary     = [NSDictionarydictionary];

    [attributesDictionary setValue:[UIFontsystemFontOfSize:18.0]forKey:NSFontAttributeName];//设置字体大小

    [attributesDictionary setValue:[UIColorpurpleColor]forKey:NSForegroundColorAttributeName];//设置文字颜色

    [attributesDictionary setValue:[UIColorwhiteColor]forKey:NSBackgroundColorAttributeName];//设置背景色

    [attributesDictionary setValue:@5forKey:NSKernAttributeName];//调整间距

    [attributesDictionary setValue:@(NSUnderlineStyleSingle) forKey:NSUnderlineStyleAttributeName];//设置下划线(NSUnderlineStyleSingle :单行下划线 NSUnderlineStyleDouble:两行下划线 )

    [attributesDictionary setValue:@(NSUnderlineStyleSingle)forKey:NSStrikethroughStyleAttributeName];//添加删除线(value值和下划线用法相同)

    [attributesDictionary setValue:@0forKey:NSVerticalGlyphFormAttributeName];//设置横排还是竖排显示,0代表横排显示

    [attributesDictionary setValue:@0.5forKey:NSObliquenessAttributeName];//设置字体倾斜度

    [attributesDictionary setValue:@1forKey:NSExpansionAttributeName];//设置扁平化

    //设置阴影:NSShadowAttributeName

    //设置段落样式:NSParagraphStyleAttributeName(数值:nit];

   // paragraph.alignment = NSTextAlignmentCenter;

0 0
原创粉丝点击