How may i customise all UITextField appearances for borderWidth?

半世苍凉 提交于 2019-12-05 17:06:36

Unfortunately the appearance proxy doesn't work on layers to do what you want you should subclass UITextField and do your customisations in the layoutSubviews method (or in the init)

You can apply this to a class extended from UITextField or any UIControl you like to style.

1. Created an extension of UITextField and added following code:

- (void)awakeFromNib{

    self.layer.borderColor = [UIColor blueColor].CGColor;
    self.layer.borderWidth = 1.0f;
}

2.1 Create UITextField inside Code

Now if you create a UITextField inside your code, #import the extension of your UITextField and create the UITextField.

2.2 Create UITextField in 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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!