uiview外的黑色

时间:2015-08-27 14:21:08

标签: ios objective-c uiview uiviewcontroller storyboard

我有这个代码在用户开始编辑时为UITextField设置动画(以保持字段在用户查看区域内的焦点)。

#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];
}

此代码效果很好,但是当我开始编辑最后一个文本字段时,会出现如下图所示的黑屏:

enter image description here

如何解决此黑屏并将此颜色更改为我视图的相同颜色(即分组表视图颜色)?

0 个答案:

没有答案