i am trying to customise all UITextField appearances for borderWith.
Trying something like this. Only first 2 lines are making a difference. Rest of the lines not working ?
[[UITextField appearance] setBackgroundColor:[UIColor greenColor]];
[[UITextField appearance] setTextColor:[UIColor blackColor]];
[UITextField appearance].layer.cornerRadius = 6.0f;
[UITextField appearance].layer.borderColor = [UIColor redColor].CGColor;
[UITextField appearance].layer.borderWidth = 3.f;
You can apply this to a class extended from UITextField or any UIControl you like to style.
extension of UITextField and added following code:- (void)awakeFromNib{
self.layer.borderColor = [UIColor blueColor].CGColor;
self.layer.borderWidth = 1.0f;
}
UITextField inside CodeNow if you create a UITextField inside your code, #import the extension of your UITextField and create the UITextField.
Interface Builder
If you create the UIButton inside the Interface Builder, select the UITextField, go to the Identity Inspector and add the created extension as class for the UITextField.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With