Advertisement
Guest User

Untitled

a guest
Jul 4th, 2015
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. import UIKit
  2.  
  3. // How to use
  4. // Drag an UIView to storyboard, set constraints.
  5. // Set the height constraint priority to less than 1000.
  6. // The view will override that to half pixel.
  7. class HairlineView: UIView {
  8. override init(frame: CGRect) {
  9. super.init(frame: frame)
  10. }
  11.  
  12. required init(coder decoder: NSCoder) {
  13. super.init(coder: decoder)
  14. }
  15.  
  16. override func updateConstraints() {
  17. let height = (1.0 / UIScreen.mainScreen().scale)
  18. addConstraint(NSLayoutConstraint(item: self, attribute: .Height, relatedBy: .Equal, toItem: nil, attribute: .Height, multiplier: 1.0, constant: height))
  19.  
  20. super.updateConstraints()
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement