简体   繁体   中英

How do I change UITextField border from itself?

I have MYTextField inherited from UITextField .

I call [self changeBorderColor] method inside MYTextField that looks like that:

self.layer.masksToBounds = YES;
self.layer.borderColor = (__bridge CGColorRef _Nullable)([UIColor brownColor]);
self.layer.borderWidth = 1;

But nothing happen. Is there way to do that?

instead of self.layer.borderColor = (__bridge CGColorRef _Nullable)([UIColor brownColor]);

write self.layer.borderColor = [UIColor brownColor].CGColor;

By using the layer property you can do like this way,

tf.layer.cornerRadius = 25.0f;
tf.layer.masksToBounds = YES;
tf.layer.borderColor = [UIColor brownColor].CGColor;
tf.layer.borderWidth = 1.5f;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM