嘿,伙计们,我还没有找到答案,所以我想我会问你们的。
[viewOggetto setFrame:aFrame];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
[viewOggetto.view setFrame:CGRectMake(0, 0, 320, 480)];
[self.view addSubview:viewOggetto.view];
[UIView commitAnimations];这是一个简单的动画,让视图显示在某个位置,然后全屏显示。我的问题是:如何让视图的内容也跟随动画?现在,我已经正确地设置了图框动画,但视图中的所有内容都会立即全屏显示。
谢谢。
发布于 2011-03-06 00:04:21
但是viewOggetto到底是什么呢?如果是UIView,为什么还要调用viewOggetto.view呢?
是UIViewController吗?您可以同时调用这两种方法:
[viewOggetto setFrame:aFrame];
[viewOggetto.view setFrame:aFrame];假设它是一个UIViewController,试试这个/ prova cosi':
[self.view addSubview:viewOggetto.view]; // you need to have it before to animate it
// initial state of the animation:
[viewOggetto.view setFrame:CGRectMake(160, 240, 1, 1)]; // zoom from center
// viewOggetto.view.alpha = 0; // eventually to add a fadeIn animation
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
// ending state of animation:
// viewOggetto.view.alpha = 1; // restore to 1 to eventually to add a fadeIn animation
[viewOggetto.view setFrame:CGRectMake(0, 0, 320, 480)];
[UIView commitAnimations];如果是UIView,只需在每个"viewOggetto.view“代码中删除".view”即可
再见,卢卡
发布于 2011-03-05 23:36:39
现在还不完全清楚你想要发生什么,而不是立即全屏显示。你是说你想让它淡出?在开始动画之前,将子视图的alpha属性设置为0,并将其添加到self.view。然后在动画中将alpha属性设置为1。
发布于 2011-03-05 23:44:53
我只是想补充一下Jim的回答。UIView动画将UIViews从一个上下文动画化为另一个上下文。如果上下文在[UIView beginAnimations:nil context:NULL];之前不存在,那么就会产生副作用。如果视图没有被添加到子视图中,则上下文将不存在。
https://stackoverflow.com/questions/5204746
复制相似问题