UIView frames reset when using autolayout

后端 未结 3 2160
轻奢々
轻奢々 2021-02-15 16:23

I\'m facing an issue. I\'m working on an app and I\'m using storyboard with Autolayout enabled. Now on one of my UIViewControllers

3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-15 17:07

    Add this:

    override func viewDidLayoutSubviews() {
        super.viewDidLayoutSubviews()
        VIEWTOFIX.setTranslatesAutoresizingMaskIntoConstraints(true)
    }
    

    Putting it in viewDidLayoutSubviews instead of viewDidLoad got rid of the layout constraint errors for me.

提交回复
热议问题