Created
February 21, 2019 10:03
-
-
Save Pircate/52a3aeb2c59695f6e997a6f3bd19242b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SnapKit | |
public struct ConstraintViewControllerDSL { | |
fileprivate let base: UIViewController | |
init(_ base: UIViewController) { | |
self.base = base | |
} | |
} | |
extension UIViewController { | |
public var snp: ConstraintViewControllerDSL { | |
return ConstraintViewControllerDSL(self) | |
} | |
} | |
public extension ConstraintViewControllerDSL { | |
var topLayoutGuide: ConstraintItem { | |
if #available(iOS 11.0, *) { | |
return base.view.safeAreaLayoutGuide.snp.top | |
} else { | |
return base.topLayoutGuide.snp.bottom | |
} | |
} | |
var bottomLayoutGuide: ConstraintItem { | |
if #available(iOS 11.0, *) { | |
return base.view.safeAreaLayoutGuide.snp.bottom | |
} else { | |
return base.bottomLayoutGuide.snp.top | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment