在iOS中会遇到字体高亮,下边是简单的代码 movie.movieName 是字符串类型
创建NSMutableAttributedString的对象,然后调节字体,最后给UILable的attributedText 赋值即可。
NSRange
range = [movie.
movieName
rangeOfString
:text];
NSMutableAttributedString *att = [[ NSMutableAttributedString alloc ] initWithString :movie. movieName ];
[att addAttribute : NSForegroundColorAttributeName
value :[ UIColor redColor ]
range :range];
NSMutableAttributedString *att = [[ NSMutableAttributedString alloc ] initWithString :movie. movieName ];
[att addAttribute : NSForegroundColorAttributeName
value :[ UIColor redColor ]
range :range];
self.viewCell.movieName.attributedText = att;