UITextField leftViewMode
@property(nonatomic) UITextFieldViewMode leftViewMode
Discussion of [UITextField leftViewMode]
The default value for this property is UITextFieldViewModeNever.
UITextField leftViewMode example.
UIView *paddingView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 5, 20)];
textField.leftView = paddingView;
textField.leftViewMode = UITextFieldViewModeAlways;
textField.leftView = paddingView;
textField.leftViewMode = UITextFieldViewModeAlways;
Example of [UITextField leftViewMode].
CGFloat leftInset = 5.0f;
UIView *leftView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, leftInset, self.bounds.size.height)];
self.leftView = leftView;
self.leftViewMode = UITextFieldViewModeAlways;
[leftView release];
UIView *leftView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, leftInset, self.bounds.size.height)];
self.leftView = leftView;
self.leftViewMode = UITextFieldViewModeAlways;
[leftView release];
UITextField leftViewMode example.
UIView *paddingView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 5, 20)];
textField.leftView = paddingView;
textField.leftViewMode = UITextFieldViewModeAlways;
and you can add UIImageView on this paddingView for your star.png
UIImageView *img=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"star.png"]];
img.frame=CGRectMake(0, 0,5, 20);
[paddingView adsubview:img];
textField.leftView = paddingView;
textField.leftViewMode = UITextFieldViewModeAlways;
and you can add UIImageView on this paddingView for your star.png
UIImageView *img=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"star.png"]];
img.frame=CGRectMake(0, 0,5, 20);
[paddingView adsubview:img];