简体   繁体   中英

UITextfield how to make border radius and keep the border shadow also radius

I have text files and I want to change the radius of it, the text field took the radius correctly but the border looks like a cut in it.

How I can make the border also to be radius? see the below image

在此输入图像描述

You can use this code. It's working well for me:

UITextField* txtfield = [[UITextField alloc]initWithFrame:CGRectMake(10, 50, 300, 32)];
[txtfield setBorderStyle:UITextBorderStyleNone];
txtfield.layer.cornerRadius = 15.0;
txtfield.layer.borderWidth = 2.0;
txtfield.layer.borderColor = [UIColor redColor].CGColor;
txtfield.layer.masksToBounds = YES;
[self.view addSubview:txtfield];

Set the background in your view , and set the borderColor to clearColor .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM