2012-07-26 36 views
-1

我想在我正在使用的iPhone应用程序之一的标签上打印ascii值。我希望输出是这样的东西。我该怎么做? enter image description here打印iPhone标签中的星号符号

+2

为什么不把文本设置为“客户的名字*”? Asterisk在大多数QWERTY键盘上都是Shift-8。 – Polynomial 2012-07-26 13:37:12

回答

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]; 
+0

非常感谢你的朋友:),我想要红色的星号颜色。我该怎么做? – Shantanu 2012-07-26 13:41:26

+0

为了使星号变为红色,你必须带上另一个标签,字体颜色为红色,文本为'*'。 – 2012-07-26 14:24:46

+0

[检出这个例子](https://github.com/mattt/TTTAttributedLabel/tree/master/TTTAttributedLabelExample)希望它能帮助你。 – 2012-07-26 14:32:04