草庐IT

ios - UIKeyboardWillChangeFrameNotification UIViewAnimationCurve 在 iOS 7 上设置为 7

coder 2023-09-22 原文

我想确定键盘将如何设置动画。在 iOS 6 上,我得到了 UIKeyboardAnimationCurveUserInfoKey 的有效值(应该是 UIViewAnimationCurve,其值来自0-3) 但该函数返回值 7。键盘如何设置动画? 7的值可以做什么?

NSConcreteNotification 0xc472900 {name = UIKeyboardWillChangeFrameNotification; userInfo = {
    UIKeyboardAnimationCurveUserInfoKey = 7;
    UIKeyboardAnimationDurationUserInfoKey = "0.25";
    UIKeyboardBoundsUserInfoKey = "NSRect: {{0, 0}, {320, 216}}";
    UIKeyboardCenterBeginUserInfoKey = "NSPoint: {160, 588}";
    UIKeyboardCenterEndUserInfoKey = "NSPoint: {160, 372}";
    UIKeyboardFrameBeginUserInfoKey = "NSRect: {{0, 480}, {320, 216}}";
    UIKeyboardFrameChangedByUserInteraction = 0;
    UIKeyboardFrameEndUserInfoKey = "NSRect: {{0, 264}, {320, 216}}";
}}

最佳答案

键盘似乎使用了未记录/未知的动画曲线。

但您仍然可以使用它。要将其转换为用于 block 动画的 UIViewAnimationOptions,请像这样将其移动 16 位

UIViewAnimationCurve keyboardTransitionAnimationCurve;
[[notification.userInfo valueForKey:UIKeyboardAnimationCurveUserInfoKey]
                           getValue:&keyboardTransitionAnimationCurve];

keyboardTransitionAnimationCurve |= keyboardTransitionAnimationCurve<<16;

[UIView animateWithDuration:0.5
                  delay:0.0
                options:keyboardTransitionAnimationCurve
             animations:^{
                // ... do stuff here
           } completion:NULL];

或者只是将其作为动画曲线传入。

UIViewAnimationCurve keyboardTransitionAnimationCurve;
[[notification.userInfo valueForKey:UIKeyboardAnimationCurveUserInfoKey]
                           getValue:&keyboardTransitionAnimationCurve];

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationCurve:keyboardTransitionAnimationCurve];
// ... do stuff here
[UIView commitAnimations];

关于ios - UIKeyboardWillChangeFrameNotification UIViewAnimationCurve 在 iOS 7 上设置为 7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19482573/

有关ios - UIKeyboardWillChangeFrameNotification UIViewAnimationCurve 在 iOS 7 上设置为 7的更多相关文章

随机推荐