Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to set uitextfield bordercolor in iphone application [duplicate]

how to set uitextfield and UITextView border color programmatically , when we enter or edit in textfield and textview.

I used this code, but doesn't change the border color for the UITextView.

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
    textField.layer.borderColor=[[UIColor cyanColor] CGColor];
}
like image 319
raman Avatar asked Mar 22 '13 14:03

raman


1 Answers

Don't Forget : #Import <QuartzCore/QuartzCore.h>

Working Code :

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
    textField.layer.cornerRadius=8.0f;
    textField.layer.masksToBounds=YES;
    textField.layer.borderColor=[[UIColor redColor]CGColor];
    textField.layer.borderWidth= 1.0f;
    return YES;
}
like image 74
Bhavin Avatar answered Sep 20 '22 23:09

Bhavin