UITextField边框颜色 [英] UITextField border color
问题描述
我真的很想把自己的颜色设置为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.
我使用background属性来设置背景颜色:
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
framework in your class:
Import QuartzCore
framework in you class:
#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屋!