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

 

 

posted @ 2016-06-12 18:43  ZY_Liang  阅读(994)  评论(0编辑  收藏  举报