iOS—textfield设置为只有下划线,并且左边有图片

释放双眼,带上耳机,听听看~!
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;

 

人已赞赏
iOS文章

iOS app中无网络页面的添加

2019-10-6 19:27:18

iOS文章

iOS 小说阅读器高效分页

2019-10-6 21:00:05

个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
有新消息 消息中心
搜索