I currently have the following code to setup a password textfield:
self.passwordTextField = [UITextField new];
self.passwordTextField.placeholder = @"Password";
self.passwordTextField.font = [UIFont systemFontOfSize:18.f];
self.passwordTextField.secureTextEntry = YES;
self.passwordTextField.returnKeyType = UIReturnKeyDone;
self.passwordTextField.delegate = self;
self.passwordTextField.backgroundColor = [UIColor colorWithRed:255 green:255 blue:255 alpha:0.64];
self.passwordTextField.layer.borderColor = [[UIColor lightGrayColor] CGColor];
self.passwordTextField.layer.borderWidth = 1.0f;
CGFloat textFieldHeight = 45.f;
CGFloat textFieldWidth = 300.f;
self.passwordTextField.frame = CGRectMake(DIALOG_VIEW_WIDTH/2.f - textFieldWidth / 2.f, 240.f, textFieldWidth, textFieldHeight);
UIImageView *icon = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"text-input-icon-password-key.png"]];
icon.frame = CGRectMake(0, 0, 45.f, 45.f);
icon.backgroundColor = [UIColor lightGrayColor];
self.passwordTextField.leftView = icon;
self.passwordTextField.leftViewMode = UITextFieldViewModeAlways;
[self.dialogView addSubview:self.passwordTextField];
which gives me this:
However, I want to add some more transparent padding to the left of the placeholder text and to the right of the image view showing the icon. Any ideas how this can be done?
Update: Thanks for the replies. I achieved this in the end by creating a UIView for the entire object with a UIImageView for the icon and a UITextField embedded in another UIView for the text. The result was as follows: