1

I just started working on objective c. On one of my projects, I implemented a library as shown in the link below.

https://github.com/jverdi/JVFloatLabeledTextField

I wanted to know if there is any way to implement underline in the text field as shown in the link below.

https://github.com/Skyscanner/SkyFloatingLabelTextField/blob/master/SkyFloatingLabelTextField/images/showcase-example.gif

thanks in advance.

Subin Babu
  • 1,515
  • 2
  • 24
  • 50
SwiftNinja95
  • 157
  • 2
  • 16

1 Answers1

3

textfield click

-(void)viewWillAppear:(BOOL)animated{
      [textfieldname addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
}

return Textfiled color change

- (void)textFieldDidChange:(UITextField *)textfield{
    CALayer *border = [CALayer layer];
    CGFloat borderWidth = 2;
    border.borderColor =[UIColor colorWithRed:111.0f/255.0f green:111.0f/255.0f blue:111.0f/255.0f alpha:1.0].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;
}

https://stackoverflow.com/a/15489967/9137841 check this it may be help you