Answers for "swift change constraint programmatically"

1

swift edit constraint programmatically

yourHeightConstraintOutlet.constant = someValue
yourView.layoutIfNeeded()
Posted by: Guest on March-04-2020
0

swift constraints programmatically

fileprivate func setupName() { 

    lblName.text = "Hello world"

    // Step 1
    lblName.translatesAutoresizingMaskIntoConstraints = false

    //Step 2
    self.view.addSubview(lblName)

    //Step 3
    NSLayoutConstraint.activate([
        lblName.centerXAnchor.constraint(equalTo: self.view.centerXAnchor),
        lblName.centerYAnchor.constraint(equalTo: self.view.centerYAnchor)
    ])
}
Posted by: Guest on June-04-2021

Code answers related to "swift change constraint programmatically"

Code answers related to "Swift"

Browse Popular Code Answers by Language