ios - 如何在现有 View Controller 之上部分加载新的 View Controller ?

标签 ios objective-c swift viewcontroller scene

目标是实现与在 iOS 上的“邮件”应用程序中创建新电子邮件完全相同的效果。

当点击邮件应用程序右下角的“撰写”按钮时,当前的 View Controller 在背景中略微淡化,一个新的 View Controller 被部分加载到它的顶部。仍然可以在屏幕顶部看到旧的 View Controller 。单击右上角的“+”按钮时,Fantastical 应用程序也会执行此操作。

最佳答案

您可以将它作为 subview Controller 添加到您当前的 View Controller 中。

// Parent View Controller

//...

let childController = ChildController()
addChildViewController(childController)

// add the child controller's view in, reframe it, animate it here
addSubview(childController.view)

// To remove the controller
childController.removeFromParentViewController()

关于ios - 如何在现有 View Controller 之上部分加载新的 View Controller ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35051371/

相关文章:

ios - Swift 类指针作为?类协议(protocol)?

ios - 如何在使用自定义 UITableViewCell 创建 UITableViewCell 后覆盖它?

ios - iOS 中 PSTCollectionView 中的 didSelectItemAtIndexPath/didDeselectItemAtIndexPath

ios - 带有粘性 header 的 UICollectionView

iphone - Cocos2d 数组中的随机对象未被调用

swift - NSDateFormatter 做错了

ios - 如何通过按 subview 中的按钮来删除以编程方式创建的 subview

ios - NSInvalidArgumentException',原因: 'Unable to parse the format string "userName like %@ password like % @"'

objective-c - 当 Core Data 中的主队列发生变化时刷新私有(private)队列

ios - View inside cell 在所有设备中具有相同的宽度,但 cell 具有不同的宽度