NSMutableAttributedString
* attributedTextString = [[
NSMutableAttributedString
alloc
]
initWithString
:
@"hahahahhahahahhiuhgilgliuglugugguglgjlgjgjgljgjgjuguyguydgasjgfglsa,g和环境的还是觉得还是计划经济健康来了来了健康哈哈哈哈哈哈"
];
//设置的是字的颜色
[attributedTextString
addAttribute
:
NSForegroundColorAttributeName
value
:[
UIColor
redColor
]
range
:NSMakeRange(
0
,
5
)];
//设置的是字的背景颜色
[attributedTextString
addAttribute
:
NSBackgroundColorAttributeName
value
:[
UIColor
greenColor
]
range
:NSMakeRange(
0
,
5
)];
//设置的时字的字体及大小
[attributedTextString
addAttribute
:
NSFontAttributeName
value
:[
UIFont
fontWithName
:
@"Arial"
size
:
1
6
]
range
:NSMakeRange(
0
,
5
)];
self
.textView
.attributedText
= attributedTextString;
[
self
.view
setBackgroundColor
:[
UIColor
whiteColor
]];
重点在
self
.textView
.attributedText
= attributedTextString;