下面是一个自定义UILabel ,通过他,可以给Label中的关键字设置颜色
#import <UIKit/UIKit.h>
#import <CoreText/CoreText.h>
#import <QuartzCore/QuartzCore.h>
@interface CustomLabel : UILabel
{
NSMutableAttributedString *_mattString;
}
//针对某节文字设置单一颜色
-(void)setSubTextColorArray:(NSArray*)colorArray subTextPositionRangeArray:(NSArray*)subTextPositionRangeArray;
//针对某节文字设置单一颜色
-(void)setSubTextColor:(UIColor*)color subTextPositionRangeArray:(NSArray*)subTextPositionRangeArray;
// 设置某段字的颜色
- (void)setColor:(UIColor *)color fromIndex:(NSInteger)location length:(NSInteger)length;
// 设置某段字的字体
- (void)setFont:(UIFont *)font fromIndex:(NSInteger)location length:(NSInteger)length;
// 设置某段字的风格
- (void)setStyle:(CTUnderlineStyle)style fromIndex:(NSInteger)location length:(NSInteger)length;
@end
#import "CustomLabel.h"
@implementation CustomLabel
- (void)deall