I have this code that animate a UITextField when the user begin edit (To keep the focus of the field within the User viewing area).
#pragma mark - Delegate TextField
- (void)textFieldDidBeginEditing:(UITextField *)textField
{
[self animateTextField: textField up: YES];
}
- (void)textFieldDidEndEditing:(UITextField *)textField
{
[self animateTextField: textField up: NO];
}
- (void) animateTextField: (UITextField*) textField up: (BOOL) up{
NSLog(@"Fui chamado");
int movementDistance = 0; // tweak as needed
const float movementDuration = 0.3f; // tweak as needed
movementDistance = textField.tag * 50;
int movement = (up ? -movementDistance : movementDistance);
[UIView beginAnimations: @"anim" context: nil];
[UIView setAnimationBeginsFromCurrentState: YES];
[UIView setAnimationDuration: movementDuration];
self.view.frame = CGRectOffset(self.view.frame, 0, movement);
[UIView commitAnimations];
}
This code works well, but when I begin editing the last textfield, appear a black screen like in this image:
How can I solve this black screen and change this color to the same color of my view (that is Grouped Table view color)?