Answers for "swift add programmatically constraint to view"

0

swift add programmatically constraint to view

// Swift3+
let imageView = UIImageView()
imageView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
  imageView.widthAnchor.constraint(equalToConstant: 16),
  imageView.heightAnchor.constraint(equalToConstant: 16),
])
self.addSubview(self.imageView)
Posted by: Guest on February-25-2022

Code answers related to "swift add programmatically constraint to view"

Code answers related to "Swift"

Browse Popular Code Answers by Language