使用block封装一段代码,
NSString
*textSupport = [
NSString
stringWithFormat
:
@"
赞
0"
];
//
让文字是深黑色
NSMutableAttributedString
*(^makeDarkGrayColor)(
NSString
*,
NSInteger
) = ^(
NSString
*text,
NSInteger
length) {
NSMutableAttributedString *attrStr = [[ NSMutableAttributedString alloc ] initWithString :text];
[attrStr addAttribute : NSForegroundColorAttributeName value :[ UIColor lightGrayColor ] range : NSMakeRange ( 0 , length)];
return attrStr;
};
NSMutableAttributedString *attrStr = [[ NSMutableAttributedString alloc ] initWithString :text];
[attrStr addAttribute : NSForegroundColorAttributeName value :[ UIColor lightGrayColor ] range : NSMakeRange ( 0 , length)];
return attrStr;
};
// 赋值
self
.
labelSupport
.attributedText = makeDarkGrayColor(
textSupport
,1
);