Guest User

Untitled

a guest
May 21st, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. override func updateConstraints() {
  2. logoImage.anchor(self.topAnchor, left: self.leftAnchor, bottom: self.bottomAnchor, right: self.rightAnchor, topConstant: 0, leftConstant: 0, bottomConstant: self.frame.height / 2, rightConstant: 0, widthConstant: 0, heightConstant: 0)
  3. label.anchor(self.logoImage.bottomAnchor, left: self.leftAnchor, bottom: nil, right: self.rightAnchor, topConstant: 12, leftConstant: 0, bottomConstant: 0, rightConstant: 0, widthConstant: 0, heightConstant: 0)
  4. super.updateConstraints()
  5.  
  6. }
  7. override func layoutSubviews() {
  8. print(self.frame.height)
  9. updateConstraints()
  10. }
  11.  
  12. var imageV = UIImageView()
  13.  
  14. override init(frame: CGRect) {
  15. super.init(frame: frame)
  16. sharedLayout()
  17. }
  18.  
  19. required init?(coder aDecoder: NSCoder) {
  20. super.init(coder: aDecoder)
  21. sharedLayout()
  22. }
  23. func sharedLayout() {
  24.  
  25. // set constraints here
  26.  
  27. self.addSubview(imageV)
  28.  
  29. self.imageV.translatesAutoresizingMaskIntoConstraints = false
  30.  
  31. self.imageV.leadingAnchor.constraint(equalTo: self.leadingAnchor).isActive = true
  32. self.imageV.trailingAnchor.constraint(equalTo: self.leadingAnchor).isActive = true
  33. self.imageV.topAnchor.constraint(equalTo: self.topAnchor).isActive = true
  34. self.imageV.bottomAnchor.constraint(equalTo: self.bottomAnchor).isActive = true
  35.  
  36.  
  37. }
  38. }
Add Comment
Please, Sign In to add comment