Animate the keyboard in sync with the UIView while edge-swiping back in iOS7

前端 未结 3 583
攒了一身酷
攒了一身酷 2020-12-12 16:43

I\'d like to get the behavior similar to Messages app (also common in most texting apps) in iOS7, where in a conversation view swiping right from the left edge of the screen

3条回答
  •  遥遥无期
    2020-12-12 17:21

    Unfortunately, there is no built-in method to do that. I really hope there will be something like UIScrollViewKeyboardDismissModeInteractive for UIViewControllers.

    For now, to do any animations in-between viewControllers, you should use a transitionCoordinator:

    - (BOOL)animateAlongsideTransition:(void (^)(id context))animation
                            completion:(void (^)(id context))completion;
    
    - (BOOL)animateAlongsideTransitionInView:(UIView *)view
                                   animation:(void (^)(id context))animation
                                  completion:(void (^)(id context))completion;
    

    For the keyboard you should do something like this:

    [self.transitionCoordinator animateAlongsideTransitionInView:self.keyboardSuperview
                                                       animation:
    ^(id context) {
        self.keyboardSuperview.x = self.view.width;
    }
                                                      completion:nil];
    

    As for keyboardSuperview - you can get that by creating a fake inputAccessoryView:

    self.textField.inputAccessoryView = [[UIView alloc] init];
    

    Then the superview will be self.textField.inputAccessoryView.superview

提交回复
热议问题