objective-c - 在 iOS 13 中以自定义高度呈现模态框

标签 objective-c iphone user-interface ios13

在 iOS 13 中,模态视图 Controller 在呈现时有一个新的行为。我发现内置的 App Photo 呈现了一个更小的 Model View Controller 。

如何呈现一个像这样的自定义尺寸的viewController,并且可以滑动到更大的高度?

smaller height

larger height

系统照片应用程序的图片截图。

最佳答案

是的,可以在 iOS 13 中以自定义高度呈现模式。 您只需将以下代码添加到您的演示模式中

 override func updateViewConstraints() {
        self.view.frame.size.height = UIScreen.main.bounds.height - 150
        self.view.frame.origin.y =  150
        self.view.roundCorners(corners: [.topLeft, .topRight], radius: 10.0)
        super.updateViewConstraints()
 }

 extension UIView {
   func roundCorners(corners: UIRectCorner, radius: CGFloat) {
        let path = UIBezierPath(roundedRect: bounds, byRoundingCorners: corners, cornerRadii: CGSize(width: radius, height: radius))
        let mask = CAShapeLayer()
        mask.path = path.cgPath
        layer.mask = mask
    }
 }

关于objective-c - 在 iOS 13 中以自定义高度呈现模态框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58007671/

相关文章:

user-interface - Flutter tabBar如何上下变化

iphone - 适用于 Mac/iPhone 的 xUnit 测试框架

ios - Xcode 8/Swift 3 和在运行 iOS 7 的 iPhone 4 上安装应用程序

c++ -::MoveWindow 的问题 - 留下空白

iphone - 子类化的 UIView 没有设置标签

iphone - 如何使用 Swift 3 检测 iPod 和 iPhone 设备?

java - 在板上移动 Snake 的 body 会导致 body 结 block

Objective C 的 Javascript 语法荧光笔

objective-c - NSTableView 内的 NSButtonCell 复选框始终获取 NSOffState。为什么?

ios - AVAssetWriter/AVAssetWriterInputPixelBufferAdaptor - 黑帧和帧率