带下拉按钮的UITextField

Maa*_*eaL 0 uibutton uitextfield ios

可以在UITextField做代码此UI单独或者我需要使用的图像或使用其他组件的呢?像按钮,标签。

屏幕截图

Dee*_*pak 5

尝试这个。

UIImageView *imgViewForDropDown = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 35, 35)];
imgViewForDropDown.image = [UIImage imageNamed:@"dropDown.png"];
yourTextField.rightView = imgViewForDropDown;
yourTextField.rightViewMode = UITextFieldViewModeAlways;
Run Code Online (Sandbox Code Playgroud)

对于Swift代码:

let imgViewForDropDown = UIImageView()
imgViewForDropDown.frame = CGRect(x: 0, y: 0, width: 30, height: 48)
imgViewForDropDown.image = UIImage(named: "ic_keyboard_arrow_down_white")
yourTextField.rightView = imgViewForDropDown
yourTextField.rightViewMode = .always
Run Code Online (Sandbox Code Playgroud)