UITextField 边框颜色 [英] UITextField border color
本文介绍了UITextField 边框颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我非常希望将自己的颜色设置为 UITextField 边框.但到目前为止,我只能找到如何更改边框线条样式.
I have really great wish to set my own color to UITextField border. But so far I could find out how to change the border line style only.
我使用背景属性以这种方式设置背景颜色:
I've used background property to set background color in such way:
self.textField.backgroundColor = textFieldColor;
但我也必须更改 UITextField 边框的颜色.我的问题是关于如何更改边框颜色.
But I have to change color of UITextField border too. And my question was about how to change the border color.
推荐答案
在你的类中导入QuartzCore
框架:
#import <QuartzCore/QuartzCore.h>
为了更改边框颜色,请使用以下代码片段(我将其设置为 redColor),
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];
在快速代码中
textField.layer.borderWidth = 1
textField.layer.borderColor = UIColor.whiteColor().CGColor
这篇关于UITextField 边框颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文