Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Presenting modal in iOS 13 with custom height

In iOS 13 there is a new behaviour for modal view controller when being presented.And I found the build-in App Photo presents a smaller model view controller.

How can I present a viewController with a custom size like this,and can slide up to a larger height?

smaller height

larger height

Picture screenshots from system photo app.

like image 569
jrjian Avatar asked Sep 19 '19 09:09

jrjian


1 Answers

Yes it is possible Presenting modal in iOS 13 with custom height. You just need to add the below code into your Presenting modal

 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
    }
 }
like image 146
Arvind Patel Avatar answered Sep 17 '22 06:09

Arvind Patel