给label text 上色 && 给textfiled placeholder 上色

1、给label text 上色:

NSInteger stringLength = ;
stringLength = model.ToUserNickName.length;
NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:string];
NSLog(@"textLength is %u", model.ToUserNickName.length);
[str addAttribute:NSForegroundColorAttributeName value:[UIColor grayColor] range:NSMakeRange(,stringLength)];
self.CommentContent.attributedText = str; // self.CommentContent.attributedText 是一个 label

2、

textField.placeholder = @"username is in here!";
[textField setValue:[UIColor redColor] forKeyPath:@"_placeholderLabel.textColor"];
[textField setValue:[UIFont boldSystemFontOfSize:] forKeyPath:@"_placeholderLabel.font"]; // 转自 http://blog.csdn.net/woaifen3344/article/details/38352015
上一篇:selenium css(转)


下一篇:java.util.Date 与 java.sql.Date 之间的转换