<分区>
当我们在文本字段和 TextView 中输入或编辑时,如何以编程方式设置 uitextfield 和 UITextView
边框颜色。
我使用了这段代码,但没有更改 UITextView
的边框颜色。
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
textField.layer.borderColor=[[UIColor cyanColor] CGColor];
}
标签 iphone ios objective-c
<分区>
当我们在文本字段和 TextView 中输入或编辑时,如何以编程方式设置 uitextfield 和 UITextView
边框颜色。
我使用了这段代码,但没有更改 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;
}
关于iphone - 如何在 iphone 应用程序中设置 uitextfield 边框颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15572466/
相关文章:
ios - 获取 UIScrollView 的屏幕截图,包括屏幕外的部分
ios - Swift:从 iOS 7 编译存档时出现段错误
ios - 如果 iPhone 用户禁用了 "Set Automatically"时区,是否仍然可以找到当前的本地时区?
iphone - View Controller 不会自动旋转到纵向倒置
objective-c - 发布版本中 rawValue 的重新声明无效
objective-c - 为什么 stringForKey 返回 null?
iphone - 没有互联网连接时 dismissModalViewController 不工作 MPMoviePlayerViewController