2010-03-12 61 views
0

我已經設置了自己的類(自定義UIView)。 我將這些customView中的兩個添加到我的UIView中作爲子視圖。 所以現在問題araises:我如何動畫子視圖?以編程方式添加子視圖的動畫

myCustomView *myCustomViewInstance = [[myCustomView alloc] initWithText:@"myText"]]; 
    [self.viewContainer addSubview:myCustomViewInstance]; 

myCustomView *myCustomViewInstance2 = [[myCustomView alloc] initWithText:@"myText2"]]; 
    [self.viewContainer addSubview:myCustomViewInstance2]; 

通常我會用動畫uiviews:

[UIView beginAnimations:nil context:nil]; 
[UIView setAnimationDuration:.5]; 
self.viewContainer = CGRectMake(20,20,320,460); 
[UIView commitAnimations]; 

在這種情況下,因爲我是動畫的觀點不是子視圖不起作用。由於當地聲明,我也無法直接訪問子視圖。有任何想法嗎?

非常感謝!

回答

1

您可以在子視圖上設置一個tag(整數),然後使用[self.viewContainer viewWithTag:]再次檢索它們。然後動畫,就像你做viewContainer一樣。

+0

謝謝偉大的工作:) 添加多個子視圖是最好的方法? – rdesign 2010-03-12 20:09:36

相關問題