UITextField 设置边框 [英] UITextField Set Border
本文介绍了UITextField 设置边框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想让我的登录界面更花哨一点.所以我想构建这样的东西:
I want to make my login interface a little bit more fancy. So I wanted to build somethin like this:
这就是我必须做的:
self.usernameTextField.layer.borderWidth = 1.0f;
self.usernameTextField.layer.borderColor = [[UIColor colorWithRed:171.0/255.0 green:171.0/255.0 blue:171.0/255.0 alpha:1.0] CGColor];
self.usernameTextField.layer.cornerRadius = 5;
self.usernameTextField.clipsToBounds = YES;
self.passwordTextField.layer.borderWidth = 2.0f;
self.passwordTextField.layer.borderColor = [[UIColor colorWithRed:171.0/255.0 green:171.0/255.0 blue:171.0/255.0 alpha:1.0] CGColor];
self.passwordTextField.layer.cornerRadius = 5;
self.passwordTextField.clipsToBounds = YES;
我如何连接它们?两个 UITextField 还是有差距的..
How can I connect them? There is still a gap between the two UITextFields..
推荐答案
像界面一样放置纯图像背景,并在该图像上放置两个文本字段,并设置如下所示的边框样式.
Put plain image background like your interface and put two text fields on that image and set boarder style like below.
[yourTextField setBorderStyle:UITextBorderStyleNone];
这篇关于UITextField 设置边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文