Custom size for Modal View loaded with Form Sheet presentation Custom size for Modal View loaded with Form Sheet presentation objective-c objective-c

Custom size for Modal View loaded with Form Sheet presentation


For iOS 8, use:

self.preferredContentSize = CGSizeMake(width, height);

I've placed this in viewDidLoad.

Swift 3

self.preferredContentSize = CGSize(width: 100, height: 100)


In Attributes inspector check Use Preferred Explicit Size

enter image description here


Setting preferredContentSize didn't work for me on iOS 11 for example when presenting EKEventEditViewController.

It works only if I override getter of preferredContentSize. Something like this:

private class CLEventEditViewController: EKEventEditViewController {    override var preferredContentSize: CGSize {        get {            if let fullSize = self.presentingViewController?.view.bounds.size {                return CGSize(width: fullSize.width * 0.5,                              height: fullSize.height * 0.75)            }            return super.preferredContentSize        }        set {            super.preferredContentSize = newValue        }    }}

enter image description hereenter image description here