UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(20, 100, 280, 30)];
textField.borderStyle = UITextBorderStyleRoundedRect;
textField.placeholder = @"默认显示文字~";
textField.leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 50, 30)];
textField.leftView.backgroundColor = [UIColor greenColor];
textField.leftViewMode = UITextFieldViewModeAlways;
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"seach.png"]];
imageView.frame = CGRectMake(0, 0, 30, 30);
[textField.leftView addSubview:imageView];
[self.view addSubview:textField];
UITextField输入框placeHolder内容前加空白 加控件
最新推荐文章于 2021-09-27 23:34:21 发布