attributedText 简单属性使用

2015-12-30  本文已影响86人  小猪圣骑士

NSBackgroundColorAttributeName

区域内字体的背景颜色

( 以下的 str 都是 NSMutableAttributedString )

[str addAttribute:NSBackgroundColorAttributeName

value:[ UIColor blackColor ]

range:NSMakeRange(1,6)];

NSBaselineOffsetAttributeName

区域内字体的设置基线偏移值

[str addAttribute:NSBaselineOffsetAttributeName

value:@(2)

range:NSMakeRange(1,6)];

@( 2 ) 是调整位置 正值上偏,负值下偏

NSFontAttributeName

区域内字体的字体

[str addAttribute:NSFontAttributeName

value:[UIFont boldSystemFontOfSize:12]

range:NSMakeRange(1, 6)];

NSForegroundColorAttributeName

区域内字体的颜色

[str addAttribute:NSForegroundColorAttributeName

value:[UIColor blackColor]

range:NSMakeRange(1, 6)];

( 待续更新... )

上一篇 下一篇

猜你喜欢

热点阅读