Swift add constraint programmatically

后端 未结 5 1762
盖世英雄少女心
盖世英雄少女心 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条回答
  •  孤城傲影
    2021-01-31 08:38

    Make sure you added the paymentTextField to your view:

    paymentTextField.translatesAutoResizingMaskIntoConstraints = false
    view.addSubview(paymentTextField)
    
    ...
    

    Add your constraints, for example paymentTextField.leftAnchor.constraint(equalTo: view.leftAnchor).isActive = true

提交回复
热议问题