iOS---textfield设置为只有下划线,并且左边有图片
2015-12-29 14:49
417 查看
self.phoneField.font
= [UIFont
systemFontOfSize:15];
self.phoneField.placeholder =@"请输入";
// 通过init来创建初始化绝大部分控件,控件都是没有尺寸
UIImageView *icon = [[UIImageViewalloc]
init];
icon.image = [UIImageimageNamed:@"phone"];
icon.width =30;
icon.height =30;
icon.contentMode =UIViewContentModeCenter;
self.phoneField.leftView =icon;
self.phoneField.leftViewMode
= UITextFieldViewModeAlways;
/** ---------------------------------------------------------------------------*/
//设置无边框(可以直接在sb中设置)
// self.phoneField.borderStyle = UITextBorderStyleNone;
//手机号
self.phoneField.font
= [UIFont
systemFontOfSize:15];
self.phoneField.placeholder =
@"请输入手机号";
UIView *line=[[UIView
alloc]initWithFrame:CGRectMake(0,self.phoneField.height-2,
self.phoneField.width,
1)];
line.backgroundColor=[UIColor
lightGrayColor];
[self.phoneField
addSubview:line];
// 通过init来创建初始化绝大部分控件,控件都是没有尺寸
UIImageView *searchIcon = [[UIImageView
alloc] init];
searchIcon.image = [UIImage
imageNamed:@"phone"];
searchIcon.width =
30;
searchIcon.height =
30;
searchIcon.contentMode =
UIViewContentModeCenter;
self.phoneField.leftView = searchIcon;
self.phoneField.leftViewMode
= UITextFieldViewModeAlways;
//密码
self.pwdField.font
= [UIFont
systemFontOfSize:15];
self.pwdField.placeholder =
@"请输入密码";
UIView *line2=[[UIView
alloc]initWithFrame:CGRectMake(0,self.pwdField.height-1,
self.pwdField.width,
1)];
line2.backgroundColor=[UIColor
lightGrayColor];
[self.pwdField
addSubview:line2];
// 通过init来创建初始化绝大部分控件,控件都是没有尺寸
UIImageView *searchIcon2 = [[UIImageView
alloc] init];
searchIcon2.image = [UIImage
imageNamed:@"pwd"];
searchIcon2.width =
30;
searchIcon2.height =
30;
searchIcon2.contentMode =
UIViewContentModeCenter;
self.pwdField.leftView = searchIcon2;
self.pwdField.leftViewMode
= UITextFieldViewModeAlways;
= [UIFont
systemFontOfSize:15];
self.phoneField.placeholder =@"请输入";
// 通过init来创建初始化绝大部分控件,控件都是没有尺寸
UIImageView *icon = [[UIImageViewalloc]
init];
icon.image = [UIImageimageNamed:@"phone"];
icon.width =30;
icon.height =30;
icon.contentMode =UIViewContentModeCenter;
self.phoneField.leftView =icon;
self.phoneField.leftViewMode
= UITextFieldViewModeAlways;
/** ---------------------------------------------------------------------------*/
//设置无边框(可以直接在sb中设置)
// self.phoneField.borderStyle = UITextBorderStyleNone;
//手机号
self.phoneField.font
= [UIFont
systemFontOfSize:15];
self.phoneField.placeholder =
@"请输入手机号";
UIView *line=[[UIView
alloc]initWithFrame:CGRectMake(0,self.phoneField.height-2,
self.phoneField.width,
1)];
line.backgroundColor=[UIColor
lightGrayColor];
[self.phoneField
addSubview:line];
// 通过init来创建初始化绝大部分控件,控件都是没有尺寸
UIImageView *searchIcon = [[UIImageView
alloc] init];
searchIcon.image = [UIImage
imageNamed:@"phone"];
searchIcon.width =
30;
searchIcon.height =
30;
searchIcon.contentMode =
UIViewContentModeCenter;
self.phoneField.leftView = searchIcon;
self.phoneField.leftViewMode
= UITextFieldViewModeAlways;
//密码
self.pwdField.font
= [UIFont
systemFontOfSize:15];
self.pwdField.placeholder =
@"请输入密码";
UIView *line2=[[UIView
alloc]initWithFrame:CGRectMake(0,self.pwdField.height-1,
self.pwdField.width,
1)];
line2.backgroundColor=[UIColor
lightGrayColor];
[self.pwdField
addSubview:line2];
// 通过init来创建初始化绝大部分控件,控件都是没有尺寸
UIImageView *searchIcon2 = [[UIImageView
alloc] init];
searchIcon2.image = [UIImage
imageNamed:@"pwd"];
searchIcon2.width =
30;
searchIcon2.height =
30;
searchIcon2.contentMode =
UIViewContentModeCenter;
self.pwdField.leftView = searchIcon2;
self.pwdField.leftViewMode
= UITextFieldViewModeAlways;
相关文章推荐
- iOS6内存警告处理
- ios下链接超时问题小记
- iOS AF 实现ssl网管认证
- ios 打包
- IOS 最新通讯录和<Contacts/Contacts.h>框架
- ios如何快速获取颜色
- 申请苹果开发者账号
- iOS相对路径
- iOS图片拉伸技巧
- Masonry学习
- iOS-----推送机制(上)
- iOS 保持界面流畅的技巧(最全最详尽的了)
- IOS AES 128 ECB PKCS7Padding 16进制加密解密
- ios7 修改导航栏的颜色
- 使用的iOS绘图方法
- ios证书的选择
- IOS8 H264硬件解码
- iOS禁用webivew的alert
- 详细讲述iOS自定义转场
- iOS 删除本地文件的方法