设置UItextfield边框颜色

iphone中,在编辑文本时怎么设置UITextView的边框颜色?

下面的代码没有实现。

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
    textField.layer.borderColor=[[UIColor cyanColor] CGColor];
}

加上:#Import <QuartzCore/QuartzCore.h>

用下面的代码就行:

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
    textField.layer.cornerRadius=8.0f;
    textField.layer.masksToBounds=YES;
    textField.layer.borderColor=[[UIColor redColor]CGColor];
    textField.layer.borderWidth= 1.0f;
    return YES;
}

UITextField的边框颜色设置:

添加 #import "QuartzCore/QuartzCore.h

textField.layer.borderColor = [UIColor lightGrayColor].CGColor; // set color as you want.
textField.layer.borderWidth = 1.0; // set borderWidth as you want.