iPhone - 不是全屏莫代尔

Spa*_*Dog 2 iphone

在我的代码的某些部分,我使用这一行

[[self navigationController] pushViewController:myController animated:YES];
Run Code Online (Sandbox Code Playgroud)

这完美地工作并推动从底部到现在的视图,完全覆盖最后一个视图.

我想知道是否有办法让它只覆盖屏幕的一部分.让我们说,只是屏幕的半个底部......

可能吗?我试图改变控制器的视图框架,但尺寸保持全屏.

谢谢.

Dav*_*har 9

您可以使用相同的视图控制器向现有视图添加新的子视图,而不是以模态方式使用新的视图控制器.

您可以使用以下内容执行"幻灯片放映"动画:

[self.view addSubview: newView];

CGRect endFrame = newView.frame; // destination for "slide in" animation
CGRect startFrame = endFrame; // offscreen source

// new view starts off bottom of screen
startFrame.origin.y += self.view.frame.size.height;
self.newImageView.frame = startFrame;

// start the slide up animation
[UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:.3];   
    newView.frame = endFrame; // slide in
[UIView commitAnimations];
Run Code Online (Sandbox Code Playgroud)