48

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 look. But the problem is I also use a placeholder and there is a border that I cannot remove. I already tried:

textOption.borderStyle = UITextBorderStyleNone;
textOption.layer.borderWidth = 0;

It didn't work. Would you please help me on that? I still can see the border of the UITextField. fyi: The UITextView that I use doesn't have this issue => There is no placeholder in UITextViews.

1
  • 1
    what about textOption.backgroundColor = [UIColor clearColor]; ... Nov 21, 2013 at 9:11

7 Answers 7

106

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

1
  • Doesn't work for me! Could it also be something else as well? Thanks!
    – Ron
    Nov 23, 2016 at 16:23
30

Just use this..

textOption.borderStyle = UITextBorderStyleNone;
[textOption setBackgroundColor:[UIColor clearColor]];
19

Swift 4 and 5 :

yourTextfield.borderStyle = .none
0
14

In Swift this worked for me :

 passwordTextField.borderStyle = UITextBorderStyle.none
8

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]];
3

You have to just set border style None

 textFieldName.borderStyle = UITextBorderStyleNone;
0
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];

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.