gpt4 book ai didi

ios - 如何仅在三个边上设置 UITextField 边框/CALayer 边框 ios

转载 作者:行者123 更新时间:2023-11-29 01:47:08 26 4
gpt4 key购买 nike

我的文本字段需要一个边框,如下图所示。我该怎么做?

enter image description here

最佳答案

试试这些..我希望它能帮助...

UITextField *txt=[[UITextField alloc]initWithFrame:CGRectMake(10, 100, 150, 30)];
[txt setBackgroundColor:[UIColor clearColor]];
[txt setPlaceholder:@"Hello my friend"];
[self.view addSubview:txt];


CALayer *border = [CALayer layer];
CGFloat borderWidth = 2;
border.borderColor = [UIColor redColor].CGColor;
border.frame = CGRectMake(0, -2, txt.frame.size.width, txt.frame.size.height);
border.borderWidth = borderWidth;
[txt.layer addSublayer:border];
txt.layer.masksToBounds = YES;

关于ios - 如何仅在三个边上设置 UITextField 边框/CALayer 边框 ios,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31780484/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com