首页 > 其他 > 详细

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

时间:2015-11-27 20:00:44      阅读:265      评论:0      收藏:0      [点我收藏+]

1、给label text 上色:

NSInteger stringLength = 0;   
        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(2,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:16] forKeyPath:@"_placeholderLabel.font"]; 


// 转自 http://blog.csdn.net/woaifen3344/article/details/38352015 

 

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

原文:http://www.cnblogs.com/cnrong/p/5001490.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!