How to hide UITextField border?

后端 未结 7 1735
星月不相逢
星月不相逢 2020-12-30 21:00

I have a UITextField and I am trying to make the UITextField border invisible so that the background and UITextField would have the same color and there would be a seamless

相关标签:
7条回答
  • 2020-12-30 21:05

    If you want to remove the textfield border you can do it directly with interface builder: enter image description here

    0 讨论(0)
  • 2020-12-30 21:07

    Just use this..

    textOption.borderStyle = UITextBorderStyleNone;
    [textOption setBackgroundColor:[UIColor clearColor]];
    
    0 讨论(0)
  • 2020-12-30 21:07

    In Swift this worked for me :

     passwordTextField.borderStyle = UITextBorderStyle.none
    
    0 讨论(0)
  • 2020-12-30 21:09
    UITextField *tfText = [[UITextField alloc] initWithFrame:CGRectMake(65, 200, 200, 30)];
        tfText.backgroundColor = [UIColor colorWithRed:0.2 green:0.9 blue:0.5 alpha:0.3];       
        tfText.textAlignment = UITextAlignmentCenter;
        // Border Style None
        [tfText setBorderStyle:UITextBorderStyleNone];
        [self.view addSubview:tfText];
        [tfText release];
    
    0 讨论(0)
  • 2020-12-30 21:11

    You have to just set border style None

     textFieldName.borderStyle = UITextBorderStyleNone;
    
    0 讨论(0)
  • 2020-12-30 21:12

    If you are using Interface Builder or Storyboard, you can select the textField, go on the Attributes inspector's tab, under the option Border Style you have 4 styles to chose from, the first one is without border.

    If doing it in code, this should work

    textOption.borderStyle = UITextBorderStyleNone;
    [textOption setBackgroundColor:[UIColor clearColor]];
    
    0 讨论(0)
提交回复
热议问题