Set UIViewController view property to custom UIView class without storyboard / nib

前端 未结 4 1918
我在风中等你
我在风中等你 2021-02-07 02:16

I have a UIViewController called LoginViewController. I want to build the view of that LoginViewController fully programmatically<

4条回答
  •  时光说笑
    2021-02-07 02:44

    You should load the custom view when LoginViewController's layout constraints are already loaded, try this:

      override func viewDidLoad() {
          super.viewDidLoad()
          let newView = LoginView(frame: view.bounds)
          view.addSubview(newView)
        }
    

提交回复
热议问题