mirror of https://github.com/SnapKit/SnapKit
Merge pull request #143 from devxoul/availability
Add availability check for iOS 8 and OS X 10.10 APIs.
This commit is contained in:
commit
552b1520f3
|
@ -138,25 +138,25 @@ internal class ConcreteConstraint: Constraint {
|
|||
}
|
||||
|
||||
internal override func activate() -> Void {
|
||||
if NSLayoutConstraint.respondsToSelector("activateConstraints:") && self.installInfo != nil {
|
||||
guard #available(iOS 8.0, OSX 10.10, *), self.installInfo != nil else {
|
||||
self.install()
|
||||
return
|
||||
}
|
||||
let layoutConstraints = self.installInfo!.layoutConstraints.allObjects as! [LayoutConstraint]
|
||||
if layoutConstraints.count > 0 {
|
||||
NSLayoutConstraint.activateConstraints(layoutConstraints)
|
||||
}
|
||||
} else {
|
||||
self.install()
|
||||
}
|
||||
}
|
||||
|
||||
internal override func deactivate() -> Void {
|
||||
if NSLayoutConstraint.respondsToSelector("deactivateConstraints:") && self.installInfo != nil {
|
||||
guard #available(iOS 8.0, OSX 10.10, *), self.installInfo != nil else {
|
||||
self.install()
|
||||
return
|
||||
}
|
||||
let layoutConstraints = self.installInfo!.layoutConstraints.allObjects as! [LayoutConstraint]
|
||||
if layoutConstraints.count > 0 {
|
||||
NSLayoutConstraint.deactivateConstraints(layoutConstraints)
|
||||
}
|
||||
} else {
|
||||
self.uninstall()
|
||||
}
|
||||
}
|
||||
|
||||
private let fromItem: ConstraintItem
|
||||
|
|
|
@ -125,6 +125,7 @@ internal struct ConstraintAttributes: OptionSetType, BooleanType {
|
|||
attrs.append(.Baseline)
|
||||
}
|
||||
#if os(iOS)
|
||||
if #available(iOS 8.0, *) {
|
||||
if (self.contains(ConstraintAttributes.FirstBaseline)) {
|
||||
attrs.append(.FirstBaseline)
|
||||
}
|
||||
|
@ -152,6 +153,7 @@ internal struct ConstraintAttributes: OptionSetType, BooleanType {
|
|||
if (self.contains(ConstraintAttributes.CenterYWithinMargins)) {
|
||||
attrs.append(.CenterYWithinMargins)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return attrs
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue