Advertisement
Guest User

Untitled

a guest
Jul 18th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. override open func layoutSubviews() {
  2. super.layoutSubviews()
  3.  
  4. let width = self.frame.width
  5. let height = self.frame.height
  6. imageView.contentMode = .scaleAspectFit
  7. imageView.topAnchor.constraint(equalTo: self.topAnchor, constant: 0.03*height).isActive = true
  8. imageView.leftAnchor.constraint(equalTo: self.leftAnchor, constant: 0.1*width).isActive = true
  9. imageView.rightAnchor.constraint(equalTo: self.rightAnchor, constant: -0.1*width).isActive = true
  10. imageView.heightAnchor.constraint(equalTo: self.heightAnchor, multiplier: 0.6).isActive = true
  11.  
  12. label.topAnchor.constraint(equalTo: imageView.bottomAnchor, constant: 0.05*height).isActive = true
  13. label.leftAnchor.constraint(equalTo: self.leftAnchor, constant: 0.1*width).isActive = true
  14. label.rightAnchor.constraint(equalTo: self.rightAnchor, constant: -0.1*width).isActive = true
  15. label.bottomAnchor.constraint(equalTo: self.bottomAnchor, constant: -0.03*height).isActive = true
  16. self.layoutIfNeeded()
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement