0

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?

enter image description here

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Aayushi
  • 787
  • 10
  • 14

3 Answers3

2

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 :

MY OUTPUT

Kirit Modi
  • 23,155
  • 15
  • 89
  • 112
1

You can put UIProgressView under your UITextField

svvoff
  • 289
  • 2
  • 14
0

Make UITextField With No Border and add UIProgressView bottom of UITextField.

progress view

Sakir Sherasiya
  • 1,562
  • 1
  • 17
  • 31