Synchronizing Animations in keyboardWillShow keyboardWillHide — Hardware Keyboard & Virtual Keyboard Simultaneously

前端 未结 2 914
青春惊慌失措
青春惊慌失措 2020-12-29 08:25

Preamble

So I have an application featuring a chat section, and I\'m synchronizing the animation of the keyboard hiding and showing with the rise and fall of the

2条回答
  •  旧时难觅i
    2020-12-29 08:41

    Since the animation curve Apple sends you in the keyboard notification does not have a corresponding UIViewAnimationOption bit, you need to drop down to old-school non-block animations and use the curve directly:

    NSTimeInterval duration = [note.userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue];
    UIViewAnimationCurve curve = [note.userInfo[UIKeyboardAnimationCurveUserInfoKey] integerValue];
    [UIView beginAnimations:@"SomeAnimationID" context:NULL];
    [UIView setAnimationCurve:curve];
    [UIView setAnimationDuration:duration];
    // Animation code
    [UIView commitAnimations];
    

提交回复
热议问题