从其superView中删除UIView并将其框架扩展为全屏

时间:2011-01-12 19:49:51

标签: iphone uiview

我有一个UIView的子类,可以作为子视图添加到视图层次结构中。我希望能够从其superView中删除UIView,并将其添加为主窗口的子视图,然后展开到全屏。

有些事情:

// Remove from superView and add to mainWindow
[self retain];
[self removeFromSuperView];
[mainWindow addSubView:self];

// Animate to full screen
[UIView beginAnimations:@"expandToFullScreen" context:nil];
[UIView setAnimationDuration:1.0];
self.frame = [[UIScreen mainScreen] applicationFrame];
[UIView commitAnimations];

[self release];

首先我是在正确的路线上吗?其次,对象是否有一种简单的方法来获取指向mainWindow的指针?

谢谢

戴夫

2 个答案:

答案 0 :(得分:3)

您可以使用视图的窗口属性

self.window

答案 1 :(得分:2)

看起来不错。但是在开始动画之前,您可能希望将视图的帧从其超视图坐标系转换为窗口的坐标系。否则动画将不顺畅。