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