Swift Add Width Height Constraint To View Without A Lot

[Solved] Swift Add Width Height Constraint To View Without A Lot | Swift - Code Explorer | yomemimo.com
Question : swift add programmatically width height constraint to view

Answered by : rens-wijnmalen

// Swift3+
let imageView = UIImageView()
imageView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([ imageView.widthAnchor.constraint(equalToConstant: 16), imageView.heightAnchor.constraint(equalToConstant: 16),
])
self.addSubview(self.imageView)

Source : | Last Update : Fri, 04 Mar 22

Answers related to swift add width height constraint to view without a lot of code

Code Explorer Popular Question For Swift