iphone - 如何设置 UITextfield 的边框样式

标签 iphone ios objective-c uitextfield

如何以编程方式设置 UITextField 的边框样式?

我正在这样创建我的文本字段:

UITextField *tfText = [[UITextField alloc] initWithFrame:CGRectMake(65, 200, 200, 30)];
tfText.backgroundColor = [UIColor colorWithRed:0.2 green:0.9 blue:0.5 alpha:0.3];       
tfText.textAlignment = UITextAlignmentCenter;
[self.view addSubview:tfText];
[tfText release];

最佳答案

试试这个

UITextField *tfText = [[UITextField alloc] initWithFrame:CGRectMake(65, 200, 200, 30)];
tfText.backgroundColor = [UIColor colorWithRed:0.2 green:0.9 blue:0.5 alpha:0.3];       
tfText.textAlignment = UITextAlignmentCenter;
// Border Style None
[tfText setBorderStyle:UITextBorderStyleNone];
[self.view addSubview:tfText];
[tfText release];

供引用

关于iphone - 如何设置 UITextfield 的边框样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5789816/

相关文章:

iphone - 使用 CALayer 作为 subview 的动画 UIView 框架

php - 带有企业应用程序的 Apple 推送通知

ios - 从 UIImage 更改 ViewController

ios - 如何在 CoreData 中为包含 NSArray 的二进制数据创建 NSPredicate?

ios - Appium iOS Error Domain=NSCocoaErrorDomain Code=260 "The file “WebDriverAgentRunner-Runner.app” 无法打开因为没有那个文件

iphone - 如何使用 zxing 库获取条码类型和格式

ios - 无法让委托(delegate)在我的观点之间工作

objective-c - Objective C iOS 预加载 View

iphone - MGTwitterEngine-isUser :receivingUpdatesFor: always return HTTP error 400?

ios - 点击 subview Controller 或父 View Controller 时处理键盘关闭的替代方法?