嘿伙计们,我还没有找到答案,所以我想我会问你。
[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];
这是一个简单的动画,可让视图出现在一个位置然后全屏显示。 我的问题是:如何让视图的内容跟随动画呢? 现在我有了正确的视图框架动画,但视图内的所有内容都会立即显示为全屏。
感谢。
答案 0 :(得分:2)
目前还不完全清楚你想要发生什么,而不是立刻出现全屏幕。你的意思是你希望它淡入?将子视图的alpha
属性设置为0
,并在开始动画之前将其添加到self.view
。然后在动画中将alpha
属性设置为1。
答案 1 :(得分:0)
只想补充Jim的答案。 UIView动画将UIViews从一个上下文动画到另一个上下文。如果在[UIView beginAnimations:nil context:NULL];
之前不存在上下文,则会发生下侧效应。如果视图尚未添加到子视图,则上下文不存在。
答案 2 :(得分:0)
但是viewOgget究竟是什么?如果它是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”
侨, 卢卡