如何更改textField的placeholder的左边距以及颜色字号等
2016-05-12 15:33
363 查看
UITextField *tfPhone = [[UITextField
alloc] init];
tfPhone.leftView = [[UIView
alloc] initWithFrame:CGRectMake(0,
0, 15,
40)];
tfPhone.leftViewMode =
UITextFieldViewModeAlways;
self.tfPhone = tfPhone;
tfPhone.delegate =
self;
tfPhone.backgroundColor =
UIColorFromRGBWithAlpha(0xd5d5d5,
1.0);
NSMutableParagraphStyle *style = [tfPhone.defaultTextAttributes[NSParagraphStyleAttributeName]
mutableCopy];
style.minimumLineHeight = tfPhone.font.lineHeight - (tfPhone.font.lineHeight
- [UIFont systemFontOfSize:14].lineHeight) /
2.0;
tfPhone.attributedPlaceholder = [[NSAttributedString
alloc]
initWithString:@"请输入您的手机号"
attributes:@{NSParagraphStyleAttributeName : style,
NSFontAttributeName : [UIFont
systemFontOfSize:14],
NSForegroundColorAttributeName: UIColorFromRGBWithAlpha(0x878787,
1.0)}];
tfPhone.textColor =
UIColorFromRGBWithAlpha(0x878787,
1.0);
[self
addSubview:tfPhone];
tfPhone.layer.cornerRadius =
5;
tfPhone.layer.masksToBounds =
YES;
alloc] init];
tfPhone.leftView = [[UIView
alloc] initWithFrame:CGRectMake(0,
0, 15,
40)];
tfPhone.leftViewMode =
UITextFieldViewModeAlways;
self.tfPhone = tfPhone;
tfPhone.delegate =
self;
tfPhone.backgroundColor =
UIColorFromRGBWithAlpha(0xd5d5d5,
1.0);
NSMutableParagraphStyle *style = [tfPhone.defaultTextAttributes[NSParagraphStyleAttributeName]
mutableCopy];
style.minimumLineHeight = tfPhone.font.lineHeight - (tfPhone.font.lineHeight
- [UIFont systemFontOfSize:14].lineHeight) /
2.0;
tfPhone.attributedPlaceholder = [[NSAttributedString
alloc]
initWithString:@"请输入您的手机号"
attributes:@{NSParagraphStyleAttributeName : style,
NSFontAttributeName : [UIFont
systemFontOfSize:14],
NSForegroundColorAttributeName: UIColorFromRGBWithAlpha(0x878787,
1.0)}];
tfPhone.textColor =
UIColorFromRGBWithAlpha(0x878787,
1.0);
[self
addSubview:tfPhone];
tfPhone.layer.cornerRadius =
5;
tfPhone.layer.masksToBounds =
YES;
相关文章推荐
- Dr.Elephant FAQ 常见问题
- 【多线程-创建新线程】
- Android 中ListView 嵌套 ListView
- Sql日期时间格式转换
- MVC中form提交和在控制器中怎样接受
- 个性化推荐漫谈
- 01.安装maven
- 点击按钮自动加关注的代码(sina微博/QQ空间/人人网/腾讯微博)
- 【OpenCV】中cvCreateImage、cvSaveImage、cvReleaseImage
- robotframework 初识
- c++简单线程池实现
- 自定义动画Animation
- Python通过Zabbix API获得数据
- iOS上传图像到服务器,以及服务器PHP接收的几种方法
- 设计模式
- [从头学声学] 第212节 辅音的数据
- Java垃圾回收机制
- 浏览器中音频兼容性问题(上)
- maven webapp后无法添加src/main/java和src/main/test
- android-如何获得当前正在运行的activity的相关信息