我有UIButton
,我想只用红色的一半标题。这是我的按钮
NSString *title = AMLocalizedString(@"Remove", nil);
NSString *title1 = [NSString stringWithFormat:title, name ];
UIButton *rem = [UIButton buttonWithType:UIButtonTypeRoundedRect];
rem.frame = CGRectMake(140, 70, 175, 40);
[rem setTitle:title1 forState:UIControlStateNormal];
删除"Remove" = "Delete object %@";
我想仅用红色name
我该怎么做?
答案 0 :(得分:1)
在NSAttributeString
UIButton's
UILabel
中使用iOS 6.0
。
yourbtn.titleLabel.attributedText = yourAttributeStringText;
请参阅NSAttributedStringInPractice链接,了解如何使用NSAttributeString
。
使用iOS 5.1
或lesser version
时可能会使用:
在UIButton's titleLabel