@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

 

 

相关文章:

  • 2022-12-23
  • 2021-08-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-26
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-20
  • 2022-12-23
相关资源
相似解决方案