EDIT #2
It seems based on the responses I've gotten that I'm confusing people (and subsequently myself). So let's try to simplify this question some -
I wish to give all TextFields in a given ViewController
the following:
textField.layer.cornerRadius=8.0f;
textField.layer.masksToBounds=YES;
[[textField layer] setBorderColor:[[UIColor colorWithRed:171.0/255.0 green:171.0/255.0 blue:171.0/255.0 alpha:1.0] CGColor]];
textField.layer.borderWidth= 1.0f;
Where should I implement this and how so that it does not give me errors for the layer property (ie when I try to do this in or after -(void)viewDidLoad
I get an error for every line stating that "Property 'layer' not found on object of type ViewController
"?
EDIT #1 Full section of subclass code to assist in identifying the issue:
@interface InputTextField : UITextField
@end
@implementation InputTextField
- (CGRect)textRectForBounds:(CGRect)bounds {
int margin = 5;
CGRect inset = CGRectMake(bounds.origin.x + margin, bounds.origin.y, bounds.size.width - margin, bounds.size.height);
return inset;
}
- (CGRect)editingRectForBounds:(CGRect)bounds {
int margin = 5;
CGRect inset = CGRectMake(bounds.origin.x + margin, bounds.origin.y, bounds.size.width - margin, bounds.size.height);
return inset;
InputTextField *textField=[[InputTextField alloc]init];
textField.layer.cornerRadius=8.0f;
textField.layer.masksToBounds=YES;
[[textField layer] setBorderColor:[[UIColor colorWithRed:171.0/255.0 green:171.0/255.0 blue:171.0/255.0 alpha:1.0] CGColor]];
textField.layer.borderWidth= 1.0f;
}
@end
ORIGINAL POST
I'm having an issue changing the Border Style and Color of a range of Text Fields within a particular View Controller. I have a bunch of Text Fields in a view that I want to adjust. They all have been given the custom class 'InputTextField'. However the solutions brought up in this thread: UITextField border color do not solve my issue.
Here's the Style and Color I'd like to achieve:
textField.layer.cornerRadius=8.0f;
textField.layer.masksToBounds=YES;
[[textField layer] setBorderColor:[[UIColor colorWithRed:171.0/255.0 green:171.0/255.0 blue:171.0/255.0 alpha:1.0] CGColor]];
textField.layer.borderWidth= 1.0f;
I've also imported QuartzCore/QuartzCore.h
. I want to set this so every TextField in my app with the custom class InputTextField
will appear with this background. At this point, whenever I run this in the app, the fields all take the background value I've set in Storyboards (currently No Border).
Thanks for the assistance!