n179911 n179911 - 9 months ago 111
Swift Question

How to set the border of UITextView to same as border color of UITextField

By default UITextField has a light gray color as its border color.
I want to set my UITextView to have the same border color as the UITextField.

I tried:

myTextView.layer.borderColor = UIColor.lightGrayColor().CGColor
myTextView.layer.borderColor = UIColor.lightTextColor().CGColor
myTextView.layer.borderColor = myTextField.layer.borderColor

They still have up to have different color.
Can you please tell me how to see teh UITextView border to match UITextField color?

Thank you.


Try this code.

UIColor *borderColor = [UIColor colorWithRed:204.0/255.0 green:204.0/255.0 blue:204.0/255.0 alpha:1.0];

myTextView.layer.borderColor = borderColor.CGColor;
myTextView.layer.borderWidth = 1.0;
myTextView.layer.cornerRadius = 5.0;

change borderWidth and cornerRadius value to get exact ui as UITextField.