styled Texts
来源:互联网 发布:大主宰 源码 编辑:程序博客网 时间:2024/06/10 15:09
1。mixed-style strings in on line of text
2。NSAttributedString / NSMutableAttributedString
3。相关属性,方法
- (id) initWithString : (NSString *) aString ; //初始化 NSMutableAttributedString,以便后续进行设置
- (void) setAttributes : (NSDictionary *) attributes range : (NSRange) aRange ; //设置某个范围内的文本属性
- (id) initWithAttributedString : (NSAttributedString *) attributedString ; //用已封装好的样式文本进行初始化
e.g.
NSString *string = @"iOS SDK";
NSMutableAttributedString *result = [ [ NSMutableAttributedString alloc ] initWithString : string ] ; // 初始化
NSDictionary *attributesForFirstWord = @{ // 设置属性集合
NSFontAttributeName : [ UIFont boldSystemFontOfSize:60.0f ] ,
NSForegroundColorAttributeName : [ UIColor redColor ] ,
NSBackgroundColorAttributeName : [ UIColor blackColor ]
} ;
NSShadow *shadow = [ [ NSShadow alloc ] init ] ;
shadow.shadowColor = [ UIColor darkGrayColor ] ;
shadow.shadowOffset = CGSizeMake (4.0f, 4.0f) ;
NSDictionary *attributesForSecondWord = @{
NSFontAttributeName : [ UIFont boldSystemFontOfSize:60.0f ] , //字体
NSForegroundColorAttributeName : [ UIColor whiteColor ] , // 前景色
NSBackgroundColorAttributeName : [ UIColor redColor ] , //背景色
NSShadowAttributeName : shadow // 阴影色
};
/* Find the string "iOS" , "SDK" in the whole string and sets its attribute */
[ result setAttributes : attributesForFirstWord range : [ string rangeOfString : @"iOS" ] ] ;
[ result setAttributes : attributesForSecondWord range : [ string rangeOfString : @"SDK" ] ] ;
return [ [ NSAttributedString alloc ] initWithAttributedString : result ] ;
- styled Texts
- 2.30 Constructing and Displaying Styled Texts
- Texts 语法
- YUI DataTable Styled ListView
- A CSS styled table
- Classifying Texts and Documents
- Drawing styled text with Uniscribe
- android-styled-dialogs库使用方法
- Classic Texts in Computer Science
- 《TextRank: Bringing Order into Texts》
- XART------generate art ascii texts.
- Google Talk styled Windows Form(翻译)
- 《React Native高效开发》之styled-components
- 使用 styled-components 加速 React 开发
- poj 2976 drop texts(二分搜索)
- Get notification texts colors and background
- Long texts in SAP BW: Modeling
- TextRank: Bringing Order into Texts阅读笔记
- OO实现ALV(二)<转>
- svn使用
- 【OpenCV】霍夫线变换
- 银行
- 软件开发流程
- styled Texts
- UTF8 - GB2312转换
- 15周项目1-折腾二维数组
- Visual Studio最好用的快捷键
- 如何让搜索引擎抓取AJAX内容?
- foobar2000播放器简单配置 [李园7舍_404]
- 她看见唯一疼她的汉游天下奶奶正向她走过来
- OO实现ALV(一)<转>
- UVa 640 Self Numbers (类似素数筛)