iOS UITextField 设置下底边
Posted ZY_Liang
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了iOS UITextField 设置下底边相关的知识,希望对你有一定的参考价值。
@interface ViewController () @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(30, 100, 160, 30)]; textField.text = @"设置textField下边框"; CALayer *bottomBorder = [CALayer layer]; bottomBorder.backgroundColor = [UIColor orangeColor].CGColor; bottomBorder.frame = CGRectMake(0.0f, textField.frame.size.height - 1, textField.frame.size.width, 1.0f); bottomBorder.backgroundColor = [UIColor blackColor].CGColor; [textField.layer addSublayer:bottomBorder]; [self.view addSubview:textField]; [self.view setBackgroundColor:[UIColor lightGrayColor]]; }
@end
以上是关于iOS UITextField 设置下底边的主要内容,如果未能解决你的问题,请参考以下文章
猫猫学iOS之UITextField右边设置图片,以及UITextField全解
IOS 怎么设置UIButton UITextField 不可点击且变灰
iOS用UITextField自定义UISearchBar遇到的布局问题