Swift add constraint programmatically

后端 未结 5 1780
盖世英雄少女心
盖世英雄少女心 2021-01-31 08:23

I add a UILabel (amountLabel) in UIViewController in storyboard editor. And then in swift file, viewDidLoad, I programatically create a

5条回答
  •  猫巷女王i
    2021-01-31 08:37

    I ran into the same problem that you described earlier. In order to make the programmatic subview, (in your case the paymentTextField) you have to add this to the subview first and then apply your constraints.

    By adding the subview to view first, this ensures both views have the same parent.

提交回复
热议问题