By using below code you can give bottom border to your text fields
-(void)giveBottomBorderToTheTextField:(UITextField *)textField{
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;
}
In the above code First we have to made border and given width i.e 2 . Then given border color to the text field by using Border.BorderColor , we have given dark grey to the border. here mask to bound shows bottom border color to the complete text field.
and now use this method in following way, here _userNameTextFieldlbl is your text field
[self giveBottomBorderToTheTextField:_userNameTextFieldlbl];
0 Comment(s)