若要在你的子視圖的位置和大小細粒度的控制,當iPhone旋轉,改變子視圖的框架中的UIViewController方法willAnimateRotationToInterfaceOrientation:duration:
。這個方法在一個動畫塊中被調用,所以你在其中創建的子視圖框架的所有更改都是動畫的。
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
if (UIInterfaceOrientationIsPortrait(toInterfaceOrientation)) {
// Portrait frames
self.subviewA.frame = CGRectMake(x, y, width, height);
self.subviewB.frame = CGRectMake(x, y, width, height);
self.subviewC.frame = CGRectMake(x, y, width, height);
} else {
// Landscape frames
self.subviewA.frame = CGRectMake(x, y, width, height);
self.subviewB.frame = CGRectMake(x, y, width, height);
self.subviewC.frame = CGRectMake(x, y, width, height);
}
}
來源
2011-05-24 06:03:51
EJV
就是這樣,謝謝。我試圖設置變形屬性,但表現出一種奇怪的方式。 – 2012-05-18 10:46:34