我有文本文件,我想更改其半径,文本字段正确地获取了半径,但边框看起来像是切口。
我怎样才能使边界也成为半径?
见下图
最佳答案
您可以使用此代码。这对我来说运作良好:
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];
在 View 中设置背景,并将 borderColor设置为clearColor 。
关于ios - UITextfield如何制作边框半径并保持边框阴影也为半径,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/10631192/