UITextField border color
Import QuartzCore
framework in you class:
#import <QuartzCore/QuartzCore.h>
and for changing the border color use the following code snippet (I'm setting it to redColor),
textField.layer.cornerRadius=8.0f; textField.layer.masksToBounds=YES; textField.layer.borderColor=[[UIColor redColor]CGColor]; textField.layer.borderWidth= 1.0f;
For reverting back to the original layout just set border color to clear color,
serverField.layer.borderColor=[[UIColor clearColor]CGColor];
in swift code
textField.layer.borderWidth = 1 textField.layer.borderColor = UIColor.whiteColor().CGColor
Try this:
UITextField *theTextFiels=[[UITextField alloc]initWithFrame:CGRectMake(40, 40, 150, 30)]; theTextFiels.borderStyle=UITextBorderStyleNone; theTextFiels.layer.cornerRadius=8.0f; theTextFiels.layer.masksToBounds=YES; theTextFiels.backgroundColor=[UIColor redColor]; theTextFiels.layer.borderColor=[[UIColor blackColor]CGColor]; theTextFiels.layer.borderWidth= 1.0f; [self.view addSubview:theTextFiels]; [theTextFiels release];
and import QuartzCore:
#import <QuartzCore/QuartzCore.h>
Import the following class:
#import <QuartzCore/QuartzCore.h>
//Code for setting the grey color for the border of the text field
[[textField layer] setBorderColor:[[UIColor colorWithRed:171.0/255.0 green:171.0/255.0 blue:171.0/255.0 alpha:1.0] CGColor]];
Replace 171.0
with the respective color number as required.