Hacer sengul Akac
Hacer sengul Akac

Reputation: 683

How to change textfield border style in objective c?

I want to change only bottom border style. Is it possible? I know this code

theTextFiels.layer.borderColor=[[UIColor blueColor]CGColor]; // border rengi
theTextFiels.layer.borderWidth= 5.0f; // border kalınlığı

but this apply the changes to all borders (up, right, left, bottom) How can I change the only bottom border color?

Upvotes: 0

Views: 5987

Answers (2)

Shubhank
Shubhank

Reputation: 21805

you won't be able to change only one side border color unless you subclass and know you way around in draw rect method of UIView.

You should try @stiles way ..making a image and then setting it as background...

Steps are : Make four images ; each with a different side as a color border you want. Then change the text field background to the appropriate one.

You should make the images as similar as to original text field ..this way you can achieve what your want,

Upvotes: 2

StilesCrisis
StilesCrisis

Reputation: 16290

You can do it using an image.

myTextField.background = [UIImage imageNamed:@"blue-line.png"];

Upvotes: 0

Related Questions