//改变UITextfield的Placeholder字体的颜色
2016-03-08 11:47
417 查看
- (void)viewDidLoad {
[super viewDidLoad];
[self changeUITextfieldColor];
}
//改变UITextfield的Placeholder字体的颜色
- (void)changeUITextfieldColor{
UITextField * textField = [[UITextField alloc]init];
//方法1
// UIColor *color = [UIColor blackColor];
// textField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"用户名" attributes:@{NSForegroundColorAttributeName: color}];
//方法2
textField.placeholder = @"用户名";
[textField setValue:[UIColor blueColor] forKeyPath:@"_placeholderLabel.textColor"];
textField.frame = CGRectMake(10, 100, 200, 50);
[self.view addSubview:textField];
}
[super viewDidLoad];
[self changeUITextfieldColor];
}
//改变UITextfield的Placeholder字体的颜色
- (void)changeUITextfieldColor{
UITextField * textField = [[UITextField alloc]init];
//方法1
// UIColor *color = [UIColor blackColor];
// textField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"用户名" attributes:@{NSForegroundColorAttributeName: color}];
//方法2
textField.placeholder = @"用户名";
[textField setValue:[UIColor blueColor] forKeyPath:@"_placeholderLabel.textColor"];
textField.frame = CGRectMake(10, 100, 200, 50);
[self.view addSubview:textField];
}
相关文章推荐
- 详解 CALayer 和 UIView 的区别和联系
- No matching provisioning profile found: Your build settings specify a provis...
- 解决The current branch is not configured for pull No value for key branch.master.merge found in confi
- [iOS]关于UILabel显示多颜色字体的问题
- 百度编辑器-Ueditor
- 对Viewcontroller在UINavigationController中入栈出栈的一点点理解
- bluez 协议栈实现3 应用层的协议栈实现分析之dbus
- Fragment UI显示重叠问题
- ERROR:invalid byte sequence for encoding"UTF8"
- 解决CE6和CE5在Platform Builder的Connectivity Options上的冲突
- git pull request工作模式
- Storyboard中的UIScrollView使用自动布局,使其能够滚动
- GPUImage遇到的坑
- Qt使用教程之使用Qt Quick UI表单(五)
- iOS 疑难杂症(什么鬼系列)— — UIButton 点击卡顿/延迟
- iOS边练边学--UIScrollView的属性简单使用,代理的简单介绍以及内容缩放
- UITableView自定义区头
- UID, EUID, SUID, FSUID
- 《iOS Human Interface Guidelines》——Tab Bar
- UIDevice、NSBundle、NSLocale-获取手机信息