UITextField Set Border

与世无争的帅哥 提交于 2019-12-13 04:50:29

问题


I want to make my login interface a little bit more fancy. So I wanted to build somethin like this:

Thats what i Have to far:

    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;

How can I connect them? There is still a gap between the two UITextFields..


回答1:


Put plain image background like your interface and put two text fields on that image and set boarder style like below.

[yourTextField setBorderStyle:UITextBorderStyleNone];



回答2:


The example you show is almost certainly using a table view. If you want to mimic it created a grouped table view with 2 static rows and add your text fields to each row. Make sure the text fields border style is set to none (it should be the default in IB), then set your placeholder text and color. If you want the icons, that is probably just a small UIImageView to the left of the text field.




回答3:


You can set your UITextField border style to none.

[self.textField setBorderStyle:UITextBorderStyleNone];

and then use custom background images, to get the desired look.




回答4:


Create your both TextField custom type. Dont set any border style.. Fix the image in ImageView and then place the two text field frame for the text in imageview.



来源:https://stackoverflow.com/questions/19635872/uitextfield-set-border

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!