-(void)setTextFiledLeftImage:(UITextField*)textFiled image:(NSString*)image forWidth:(CGFloat)leftWidth
{
CGRect frame = textFiled.frame;
frame.size.width = leftWidth;
UIView *leftview = [[UIView alloc] initWithFrame:frame];
UIImageView *leftImage = [[UIImageView alloc] initWithFrame:CGRectMake(10, (FUll_VIEW_HEIGHT*0.08 -23)/2, 20, 23)];
leftImage.image = [UIImage imageNamed:image];
[leftview addSubview:leftImage];
textFiled.leftViewMode = UITextFieldViewModeAlways;
textFiled.leftView = leftview;
}
账户和密码引用
[self setTextFiledLeftImage:self.UserName image:@"手机@2x.png" forWidth:50];
[self setTextFiledLeftImage:self.PassWord image:@"密码@2x.png" forWidth:50];
单纯的空几个格
-(void)setTextFiledLeft:(UITextField*)textFiled forWidth:(CGFloat)leftWidth
{
CGRect frame = textFiled.frame;
frame.size.width = leftWidth;
UIView *leftview = [[UIView alloc] initWithFrame:frame];
textFiled.leftViewMode = UITextFieldViewModeAlways;
textFiled.leftView = leftview;
}