Home > OS >  how can set viewController height when I click the button?
how can set viewController height when I click the button?

Time:10-24

how can set viewController height when I click the button?

The button use segue method to link LoginViewController to RegisterViewController

enter image description here

And the code is

class LoginViewController: UIViewController {
    
    
    override func viewDidLoad() {
        super.viewDidLoad()

    }
}

But when I click the register button, the height is too high, can I set height ?

enter image description here

CodePudding user response:

Let me get the pedantic part of this out of the way. ViewControllers do not have a height. The view that the UIViewController owns will have a height, but the view controller itself does not have a height.

It looks like you are using a Storyboard to manage your UI. The system will simulate a view controller as being full screen unless you tell it otherwise. So switch your View Controller to freeform sizing:

Setting Freeform Sizing for View Controller

Note Changing the size in this view only changes the size of the view in Interface Builder it does not change the size of the view when loaded.

To change the size of the view when it's loaded, select the view that is owned by your view controller and change its size in the size inspector:

Change the View's size

CodePudding user response:

this is called bottom sheet i use this pod to achieve this. Here is the Link
Usage

    let storyboard = UIStoryboard(name: "Main", bundle: nil)
        let vc = storyboard.instantiateViewControllerWithIdentifier("YourVC") as! YourVC 
        let controller = SheetViewController(controller: vc, sizes:[.fixed(375)])
  present(controller, animated: true, completion: nil)
  • Related