首页 > 解决方案 > 如何调整呈现视图的大小 - Swift 5 (Xcode)

问题描述

我有一个按钮,它将引导到集合视图控制器drawDetails_VC

func showController() {

    let drawDetails_VC = DrawDetails(collectionViewLayout: UICollectionViewFlowLayout())
    navigationController?.navigationBar.tintColor = UIColor.white

    let navController = CustomNavigationController(rootViewController: drawDetails_VC)
    present(navController, animated: true, completion: nil)
}

更新到Swift 5后,呈现的集合视图Page Sheet没有覆盖全屏。 在此处输入图像描述

我尝试了几个小时,但没有得到我想要的。

呈现的页面页表如何覆盖整个屏幕而不是如上图。以及如何以编程方式获得呈现的控制器页面表的宽度

标签: iosswiftuikitpresentviewcontroller

解决方案


将视图控制器的模态演示样式设置为.fullScreen.overFullScreen。试试下面的代码示例。

func showController() {
    let drawDetails_VC = DrawDetails(collectionViewLayout: UICollectionViewFlowLayout())
    navigationController?.navigationBar.tintColor = .white
    let navController = CustomNavigationController(rootViewController: drawDetails_VC)
    navController.modalPresentationStyle = .fullScreen
    present(navController, animated: true, completion: nil)
}

推荐阅读