I would like to keep the progress bar at bottom part only in UITextField
. But I don't know how we can keep it for the bottom side.
How can I achieve this?
I would like to keep the progress bar at bottom part only in UITextField
. But I don't know how we can keep it for the bottom side.
How can I achieve this?
You have to do following code for processing textfield with its characters.
STEP 1 IBOutlet connection of textfield and also delegate connection.
STEP 2 Take one layer CALayer
.
CALayer *board;
STEP 3 Init layer in ViewDidLoad.
- (void)viewDidLoad {
[super viewDidLoad];
board = [CALayer layer];
}
STEP 4 textFiled Delegate method. Here I will Apply the logic for Phone number with static, You can Apply your logic according to requirement.
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
NSLog(@"range %lu",(unsigned long)range.location);
if ([textField.layer.sublayers containsObject:board]) {
[board removeFromSuperlayer];
}
CGFloat borderWidth = 2;
board.borderColor = [UIColor darkGrayColor].CGColor;
board.frame = CGRectMake(0, textField.frame.size.height - borderWidth, (textField.frame.size.width / 10.0) * range.location, textField.frame.size.height);
board.borderWidth = borderWidth;
[textField.layer addSublayer:board];
return true;
}
Your OUTPUT :