2013-10-20 49 views
6

我期待確定鍵盤如何進行動畫處理。在iOS 6上,我獲得了UIKeyboardAnimationCurveUserInfoKey(其值應該是UIViewAnimationCurve,值爲0-3)的有效值,但是函數返回值7.如何鍵盤動畫? 7的值可以做什麼?UIKeyboardWillChangeFrameNotification在iOS 7上將UIViewAnimationCurve設置爲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}}"; 
}} 
+1

請參閱http://stackoverflow.com/questions/18957476/ios-7-keyboard-animation&http://stackoverflow.com/questions/18837166/how-to-mimic-keyboard-animation-on-ios- 7至外接完成按鈕到數字,keyboar –

回答

18

看起來,鍵盤正在使用無證/未知的動畫曲線。

但是你仍然可以使用它。將其轉換爲一個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]; 
1

我不能評論不幸,否則我不會輸入一個新的答案。

您還可以使用:

animationOptions | = animationCurve < < 16;

這可能是首選,因爲它將保留之前的OR =對動畫選項的操作。