如何在 xcode 6 中设置 UItextfield 边框颜色

how to set UItextfield border color in xcode 6

我一直在尝试(数周)在 xcode 6 中设置 uitextfield/view 边框颜色,但仍然无法正常工作。我已经尝试过我在 Whosebug 和其他论坛上找到的任何解决方案,但仍然无法正常工作。我使用 Objective-C 有什么帮助吗?谢谢

首先你需要在你的实现文件中导入核心图形文件:

#import <QuartzCore/QuartzCore.h>

然后使用此代码更改边框颜色:

 txtPass.layer.borderColor=[[UIColor redColor]CGColor];
 txtPass.layer.borderWidth= 1.0f;

如果你想给边框然后使用

 txtPass.layer.cornerRadius=8.0f;
 txtPass.layer.masksToBounds=YES;

这是我的制作方法!非常感谢大家