我正在尝试在我正在处理的一个 iPhone 应用程序的标签中打印 ascii 值。我希望输出是这样的。我该怎么做?
问问题
896 次
1 回答
1
myLabel.text = @"Cutomer's First Name*";
为制作不同颜色的文本而编辑,您可以使用TTTAttributedLabel。下面是代码
TTTAttributedLabel *label = [[TTTAttributedLabel alloc] initWithFrame:CGRectMake(20, 20, 200, 200)];
NSString* text = @"Cutomer's First Name*";
[label setText:text afterInheritingLabelAttributesAndConfiguringWithBlock:^(NSMutableAttributedString *mutableAttributedString){
//NSMutableAttributedString *mutableAttributedString;
NSRange whiteRange = [text rangeOfString:@"*"];
if (whiteRange.location != NSNotFound) {
[mutableAttributedString addAttribute:(NSString *)kCTForegroundColorAttributeName value:(id)[UIColor redColor].CGColor range:whiteRange];
}
return mutableAttributedString;
}];
label.font = [UIFont fontWithName: @"Helvetica Neue" size: 10];
于 2012-07-26T13:38:03.533 回答