textField中含有图片,文字在图片后显示

UITextField *numberTF = [[UITextField alloc]init];
numberTF.frame = CGRectMake(5, 200, UISCREEN_WIDTH-10, 50);
numberTF.borderStyle = UITextBorderStyleRoundedRect;
numberTF.placeholder = @"请输入您的账号";
[numberTF setValue:[UIColor greenColor] forKeyPath:@"_placeholderLabel.textColor"];
numberTF.textColor = [UIColor greenColor];
UIImageView *numberIV = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"login_ic01.png"]];
numberIV.frame = CGRectMake(10, 10, 30, 30);
[numberTF addSubview:numberIV];
numberTF.delegate = self;
numberTF.leftView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 35, 50)];
numberTF.leftViewMode = UITextFieldViewModeAlways;
[self.view addSubview:numberTF];

UITextField *pwdTF = [[UITextField alloc]init];
pwdTF.frame = CGRectMake(5, 260, UISCREEN_WIDTH-10, 50);
pwdTF.borderStyle = UITextBorderStyleRoundedRect;
pwdTF.placeholder = @"请输入您的密码";//含有8个空格
[pwdTF setValue:[UIColor greenColor] forKeyPath:@"_placeholderLabel.textColor"];
pwdTF.textColor = [UIColor greenColor];
UIImageView *pwdIV = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"login_ic02.png"]];
pwdIV.frame = CGRectMake(10, 10, 30, 30);
[pwdTF addSubview:pwdIV];
pwdTF.delegate = self;
pwdTF.secureTextEntry = YES;//密码以黑点显示
pwdTF.leftView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 35, 50)];
pwdTF.leftViewMode = UITextFieldViewModeAlways;
[self.view addSubview:pwdTF];




你可能感兴趣的:(UITextField)