Search code examples
iosiphoneobjective-cipaduistoryboard

How to set custom size for UIModal View in storyboard


I am developing an iPad application using storyboard.For my application i developed a modal view by setting presentation style of the modal view controller to Form sheet.Is any option available in storyboard for reduce the size of the modal view.


Solution

  • I think the better option is to set the custom size by programatically.

    objectiveC:

    - (void)viewWillLayoutSubviews{
        [super viewWillLayoutSubviews];   
        self.view.superview.bounds = CGRectMake(0, 0, <width>, <height>);
    }
    

    Swift:

    override func viewWillLayoutSubviews() {
        super.viewWillLayoutSubviews()
        self.view.superview?.bounds = CGRect(x: 0, y: 0, width: 300, height: 400)
    }
    

    Put this code inside Modal view controller