1
如果我設置了我的視圖的自動調整大小掩碼,那麼它們將在設備旋轉過程中與主窗口一起調整大小。動畫調整旋轉期間的視圖大小無需自動調整
有沒有一種方法可以通過使用我自己的動畫獲得相同的平滑性能並且不需要autoresize?
如果我設置了我的視圖的自動調整大小掩碼,那麼它們將在設備旋轉過程中與主窗口一起調整大小。動畫調整旋轉期間的視圖大小無需自動調整
有沒有一種方法可以通過使用我自己的動畫獲得相同的平滑性能並且不需要autoresize?
是的,你當然可以使用UIView動畫來移動元素。
此外,常見的技術是隱藏接口的
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
部分重繪,並顯示它作爲
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
這裏部是一個例子:
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3f];
self.myTable.hidden = YES;
...
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
[UIView commitAnimations];
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
[self redrawInterface];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3f];
self.myTable.hidden = NO;
...
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
[UIView commitAnimations];
}
稍微擴展一下;如果您沒有設置animationDuration或animationCurve,那麼您將獲得用於旋轉動畫的相同默認值。它不只是隱藏的,你可以改變,它是任何動畫的屬性(使用蘋果術語,幫助搜索)。這些包括框架/邊界和中心以及變換屬性。您可以使用transform屬性進行任何類型的翻譯,縮放或旋轉。但要小心; transform屬性會掛鉤到合成器(即視圖的緩衝版本),而不是執行任何CPU上的工作。 – Tommy 2010-11-03 21:53:46