Add image to UITextField in Xcode?

后端 未结 9 928
时光取名叫无心
时光取名叫无心 2020-12-23 08:41

\"enter

I need to implement the concept of dropdown in Xcode.

For

相关标签:
9条回答
  • 2020-12-23 09:38

    Swift 3.0

    txtField.rightViewMode = .always
    txtField.rightView = UIImageView(image: UIImage(named: "selectdrop"))
    

    0 讨论(0)
  • 2020-12-23 09:43

    UITextField has the following property:

    @property(nonatomic, retain) UIImage *background
    

    example:

    UITextField *myTextField = [[UITextField alloc] init];
    myTextField.background = [UIImage imageNamed:@"myImage.png"];
    
    0 讨论(0)
  • 2020-12-23 09:44

    UITextField has a rightView property, if you have image like this- enter image description here then You can easly set ImageView object to rightView:

    UITextField *myTextField = [[UITextField alloc] init];
    
    myTextField.rightViewMode = UITextFieldViewModeAlways;
    myTextField.rightView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"downArrow.png"]];
    0 讨论(0)
提交回复
热议问题