Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import UIKit
- // How to use
- // Drag an UIView to storyboard, set constraints.
- // Set the height constraint priority to less than 1000.
- // The view will override that to half pixel.
- class HairlineView: UIView {
- override init(frame: CGRect) {
- super.init(frame: frame)
- }
- required init(coder decoder: NSCoder) {
- super.init(coder: decoder)
- }
- override func updateConstraints() {
- let height = (1.0 / UIScreen.mainScreen().scale)
- addConstraint(NSLayoutConstraint(item: self, attribute: .Height, relatedBy: .Equal, toItem: nil, attribute: .Height, multiplier: 1.0, constant: height))
- super.updateConstraints()
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement