我只是試圖以最簡單的方式向上移動兩個視圖,我無法弄清楚如何使它在iOS8上工作(但它的工作在iOS7上很好)。IOS 8.1的動畫問題
我讀過的變化發生,但我不能讓反正它的工作...
這裏是我使用的代碼:
的CGRect txFrame; //我的textview的初始框架 CGRect btFrame; //我的按鈕的初始幀
- (void)kbWillShow{
[UIView animateWithDuration:0.45 animations:^{
//Remembering the initial frames here
txFrame = _txReason.frame;
btFrame = _btSend.frame;
_lbTitleReason.alpha = 0.3;
//Animating
_txReason.frame = CGRectMake(txFrame.origin.x, txFrame.origin.y-55, txFrame.size.width, txFrame.size.height);
_btSend.frame = CGRectMake(btFrame.origin.x, btFrame.origin.y-75, btFrame.size.width, btFrame.size.height);
}completion:nil];
}
- (void)kbWillHide{
[UIView animateWithDuration:0.45 animations:^{
//Putting them back to their original positions.
_txReason.frame = txFrame;
_btSend.frame = btFrame;
_lbTitleReason.alpha = 1;
}completion:nil];
}
我試圖把「結果」位置完成塊,但我只是做了非常突然和奇怪的運動,而duraton後視圖傳送點到intented位置。 (這比做一個突然的動作更好,並且最終在它開始的同一個位置結束)。
這應該很簡單,我做錯了什麼?
在你的情況下,你應該使用'center'屬性來代替'frame'。 – holex 2014-11-21 15:41:39
我想我已經嘗試過,但也許不正確,你能給我一個例子嗎? – Smiless 2014-11-21 15:44:03
例子...?你應該做同樣的事情,但是用'center'屬性而不是'frame'。我不確定你想看哪個例子。編寫此註釋需要更多時間,而不是改變使用'center'屬性的實際代碼。 :) – holex 2014-11-21 15:46:55