iOS UIButton 显示不同的字体颜色
作者:
我的天空蔚蓝色 | 来源:发表于
2015-12-02 17:18 被阅读4023次- (void)viewDidLoad {
[super viewDidLoad];
NSString * aStr = @"交流群246807516";
NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@",aStr]];
[str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Arial-BoldItalicMT" size:16.0] range:NSMakeRange(0,3)];
[str addAttribute:NSForegroundColorAttributeName value:[UIColor greenColor]range:NSMakeRange(0,3)];
UIButton * butn = [UIButton buttonWithType:UIButtonTypeCustom];
butn.backgroundColor = [UIColor orangeColor];
butn.frame = CGRectMake(100, 200, 200, 30);
[butn setAttributedTitle:str forState:UIControlStateNormal];
[butn addTarget:self action:@selector(click) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:butn];
}
本文标题:iOS UIButton 显示不同的字体颜色
本文链接:https://www.haomeiwen.com/subject/jxxshttx.html
网友评论