在Ios中创建仅具有底行的文本字段

问题描述:

可以在Ios中创建一个文本字段,该文本字段仅显示底边框线,不显示上边框线和边线.如果是,我该如何实现

Is is possible to create a Textfield in Ios which shows only bottom border line and not upper and side lines. if Yes, how can i implement this

是可以的.这是操作方法:

Yes it is possible. Here is how to do it:

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

希望这会有所帮助!