簡體   English   中英

UITextfield如何制作邊框半徑並保持邊框陰影也是半徑

[英]UITextfield how to make border radius and keep the border shadow also radius

我有文本文件,我想改變它的半徑,文本字段正確地取半徑,但邊框看起來像是一個切口。

我怎樣才能使邊界成為半徑? 見下圖

在此輸入圖像描述

您可以使用此代碼。 它對我有用:

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];

在視圖中設置背景 ,並將borderColor設置為clearColor

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM