呃 不会上传本地图片啊 伤啊伤啊伤..........
今天看了看样式文本,正好自己的项目也有用到,简单写了一个Demo,留存一下~~~
代码如下:
/**
* 根据按钮Title设定Label文字
*/
- (IBAction)buttonPressed:(UIButton *)sender {
NSString *title = [sendertitleForState: UIControlStateNormal];
NSString *plainText = [NSStringstringWithFormat: @"%@ button pressed", title];
// _statusLabel.text = plainText; // 将按钮文本显示在Label上.
// 使用样式文本 NSMutableAttributedString
NSMutableAttributedString *styledText = [[NSMutableAttributedStringalloc] initWithString: plainText];
// 用于保存字符串属性 NSFontAttributeName可为属性字符串的一部分设定字体.字体大小与当前使用字体大小一致.
NSDictionary *attributes =@{NSFontAttributeName: [UIFontboldSystemFontOfSize: _statusLabel.font.pointSize]};
// 需要着重显示的内容范围
NSRange nameRange = [plainText rangeOfString: title];
[styledText setAttributes: attributes range: nameRange];
_statusLabel.attributedText = styledText;
}