Swift Func For Constraint

[Solved] Swift Func For Constraint | Swift - Code Explorer | yomemimo.com
Question : swift func for constraint

Answered by : sarwar

//https://stackoverflow.com/a/26181982/13171606
//open link for further info
override func viewDidLoad() { let newView = UIView() newView.backgroundColor = UIColor.red view.addSubview(newView) newView.translatesAutoresizingMaskIntoConstraints = false newView.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true newView.centerYAnchor.constraint(equalTo: view.centerYAnchor).isActive = true newView.widthAnchor.constraint(equalToConstant: 100).isActive = true newView.heightAnchor.constraint(equalToConstant: 100).isActive = true
}

Source : https://stackoverflow.com/a/26181982/13171606 | Last Update : Sat, 20 Feb 21

Question : swift constraints

Answered by : happy-hyena-j4t6squdpbx2

 - firstView.coverWholeSuperview() - firstView.constraints(size: CGSize(width: 44, height: 44), centerX: view.centerXAnchor, centerY: view.centerXAnchor) - firstView.constraints(top: view.topAnchor, leading: secondView.leadingAnchor, bottom: view.bottomAnchor, trailing: secondView.trailingAnchor, padding: UIEdgeInsets(top: 12, left: 12, bottom: 12, right: 12))

Source : https://stackoverflow.com/questions/26180822/how-to-add-constraints-programmatically-using-swift | Last Update : Tue, 15 Jun 21

Answers related to swift func for constraint

Code Explorer Popular Question For Swift