博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
iOS开发富文本
阅读量:5158 次
发布时间:2019-06-13

本文共 2514 字,大约阅读时间需要 8 分钟。

 

 

NSMutableAttributedString * attributedStr = [[NSMutableAttributedString alloc] initWithString:@"犯我中华者,虽远必诛"];

    

    [attributedStr setAttributes:@{NSForegroundColorAttributeName:[UIColor redColor],NSFontAttributeName:[UIFont systemFontOfSize:30]} range:NSMakeRange(0, 5)];

    [attributedStr setAttributes:@{NSShadowAttributeName:[UIColor yellowColor],NSFontAttributeName:[UIFont systemFontOfSize:35]} range:NSMakeRange(2, 2)];

    [attributedStr setAttributes:@{NSForegroundColorAttributeName:[UIColor colorWithRed:215/255.0 green:0 blue:18/255.0 alpha:0.9],NSFontAttributeName:[UIFont systemFontOfSize:30]} range:NSMakeRange(6, 4)];

    

    self.attributedStr.attributedText = attributedStr;

 

//属性值

// Predefined character attributes for text. If the key is not in the dictionary, then use the default values as described below.

 NSFontAttributeName                 // UIFont, default Helvetica(Neue) 12

 NSParagraphStyleAttributeName       // NSParagraphStyle, default defaultParagraphStyle

 NSForegroundColorAttributeName     // UIColor, default blackColor

 NSBackgroundColorAttributeName      // UIColor, default nil: no background

 NSLigatureAttributeName          // NSNumber containing integer, default 1: default ligatures, 0: no ligatures

 NSKernAttributeName         // NSNumber containing floating point value, in points; amount to modify default kerning. 0 means kerning is disabled.

 NSStrikethroughStyleAttributeName  // NSNumber containing integer, default 0: no strikethrough

NSUnderlineStyleAttributeName       // NSNumber containing integer, default 0: no underline

 NSStrokeColorAttributeName         // UIColor, default nil: same as foreground color

NSStrokeWidthAttributeName        // NSNumber containing floating point value, in percent of font point size, default 0: no stroke; positive for stroke alone, negative for stroke and fill (a typical value for outlined text would be 3.0)

 NSShadowAttributeName           // NSShadow, default nil: no shadow

 NSTextEffectAttributeName          // NSString, default nil: no text effect

 NSAttachmentAttributeName           // NSTextAttachment, default nil

 NSLinkAttributeName       // NSURL (preferred) or NSString

NSBaselineOffsetAttributeName      // NSNumber containing floating point value, in points; offset from baseline, default 0

 NSUnderlineColorAttributeName      // UIColor, default nil: same as foreground color

NSStrikethroughColorAttributeName 

 NSObliquenessAttributeName 

 NSExpansionAttributeName 

 

 NSWritingDirectionAttributeName 

 

NSVerticalGlyphFormAttributeName 

 

/************************ Attribute values ************************/

 

转载于:https://www.cnblogs.com/jianbo-su/p/5691904.html

你可能感兴趣的文章
解决MFC对话框类不能建立成功的方法(出现 unable to open the files)
查看>>
南阳ACM 题目811:变态最大值 Java版
查看>>
.NET中的异步编程(三)- Continuation passing style
查看>>
周计划总结
查看>>
SpringBoot集成Socket服务后打包(war包)启动时如何启动Socket服务(web应用外部tomcat启动)...
查看>>
聊一聊深度学习的activation function
查看>>
Hibernate一级缓存
查看>>
jQuery鼠标经过图片切换
查看>>
listview和简单的记事本操作
查看>>
ssis包部署
查看>>
pat 1006 Sign In and Sign Out (25)
查看>>
shell
查看>>
poj1459 最大流Dinic
查看>>
20155320 2016-2017-2《Java程序设计》第十周学习总结
查看>>
第4次作业类测试代码+149+肖雷
查看>>
xshell SSH 连接出现 outgoing encryption ,或者no matching host key algorithm found错误的解决...
查看>>
第三方库Mantle的简单实用
查看>>
算法45----逆波兰数【栈】
查看>>
jar包重启脚本-restart.sh
查看>>
P3372 【模板】线段树 1
查看>>