Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SWIFT

swift add programmatically width height 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)
 
PREVIOUS NEXT
Tagged: #swift #add #programmatically #width #height #constraint #view
ADD COMMENT
Topic
Name
6+2 =