开发者

Animate programmatically added subviews

I've setup an own class(custom UIView). I'am adding two of these customViews to my UIView as subviews. So now the question araises: How do I animate the subviews?

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

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

Normally I would animate uiviews with:

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

In this case that doesn't work because I am animating the view not the subviews. I also can not aces开发者_StackOverflow社区s the subviews directly because of the local declaration. Any Ideas?

Thanks a lot!


You can set a tag (an integer) on your subviews and retrieve them again with [self.viewContainer viewWithTag:]. Then animate as you do with the viewContainer.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜