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,24 +138,24 @@ internal class ConcreteConstraint: Constraint {
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override func activate() -> Void {
|
internal override func activate() -> Void {
|
||||||
if NSLayoutConstraint.respondsToSelector("activateConstraints:") && self.installInfo != nil {
|
guard #available(iOS 8.0, OSX 10.10, *), self.installInfo != nil else {
|
||||||
let layoutConstraints = self.installInfo!.layoutConstraints.allObjects as! [LayoutConstraint]
|
|
||||||
if layoutConstraints.count > 0 {
|
|
||||||
NSLayoutConstraint.activateConstraints(layoutConstraints)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
self.install()
|
self.install()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
let layoutConstraints = self.installInfo!.layoutConstraints.allObjects as! [LayoutConstraint]
|
||||||
|
if layoutConstraints.count > 0 {
|
||||||
|
NSLayoutConstraint.activateConstraints(layoutConstraints)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override func deactivate() -> Void {
|
internal override func deactivate() -> Void {
|
||||||
if NSLayoutConstraint.respondsToSelector("deactivateConstraints:") && self.installInfo != nil {
|
guard #available(iOS 8.0, OSX 10.10, *), self.installInfo != nil else {
|
||||||
let layoutConstraints = self.installInfo!.layoutConstraints.allObjects as! [LayoutConstraint]
|
self.install()
|
||||||
if layoutConstraints.count > 0 {
|
return
|
||||||
NSLayoutConstraint.deactivateConstraints(layoutConstraints)
|
}
|
||||||
}
|
let layoutConstraints = self.installInfo!.layoutConstraints.allObjects as! [LayoutConstraint]
|
||||||
} else {
|
if layoutConstraints.count > 0 {
|
||||||
self.uninstall()
|
NSLayoutConstraint.deactivateConstraints(layoutConstraints)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -125,32 +125,34 @@ internal struct ConstraintAttributes: OptionSetType, BooleanType {
|
||||||
attrs.append(.Baseline)
|
attrs.append(.Baseline)
|
||||||
}
|
}
|
||||||
#if os(iOS)
|
#if os(iOS)
|
||||||
if (self.contains(ConstraintAttributes.FirstBaseline)) {
|
if #available(iOS 8.0, *) {
|
||||||
attrs.append(.FirstBaseline)
|
if (self.contains(ConstraintAttributes.FirstBaseline)) {
|
||||||
}
|
attrs.append(.FirstBaseline)
|
||||||
if (self.contains(ConstraintAttributes.LeftMargin)) {
|
}
|
||||||
attrs.append(.LeftMargin)
|
if (self.contains(ConstraintAttributes.LeftMargin)) {
|
||||||
}
|
attrs.append(.LeftMargin)
|
||||||
if (self.contains(ConstraintAttributes.RightMargin)) {
|
}
|
||||||
attrs.append(.RightMargin)
|
if (self.contains(ConstraintAttributes.RightMargin)) {
|
||||||
}
|
attrs.append(.RightMargin)
|
||||||
if (self.contains(ConstraintAttributes.TopMargin)) {
|
}
|
||||||
attrs.append(.TopMargin)
|
if (self.contains(ConstraintAttributes.TopMargin)) {
|
||||||
}
|
attrs.append(.TopMargin)
|
||||||
if (self.contains(ConstraintAttributes.BottomMargin)) {
|
}
|
||||||
attrs.append(.BottomMargin)
|
if (self.contains(ConstraintAttributes.BottomMargin)) {
|
||||||
}
|
attrs.append(.BottomMargin)
|
||||||
if (self.contains(ConstraintAttributes.LeadingMargin)) {
|
}
|
||||||
attrs.append(.LeadingMargin)
|
if (self.contains(ConstraintAttributes.LeadingMargin)) {
|
||||||
}
|
attrs.append(.LeadingMargin)
|
||||||
if (self.contains(ConstraintAttributes.TrailingMargin)) {
|
}
|
||||||
attrs.append(.TrailingMargin)
|
if (self.contains(ConstraintAttributes.TrailingMargin)) {
|
||||||
}
|
attrs.append(.TrailingMargin)
|
||||||
if (self.contains(ConstraintAttributes.CenterXWithinMargins)) {
|
}
|
||||||
attrs.append(.CenterXWithinMargins)
|
if (self.contains(ConstraintAttributes.CenterXWithinMargins)) {
|
||||||
}
|
attrs.append(.CenterXWithinMargins)
|
||||||
if (self.contains(ConstraintAttributes.CenterYWithinMargins)) {
|
}
|
||||||
attrs.append(.CenterYWithinMargins)
|
if (self.contains(ConstraintAttributes.CenterYWithinMargins)) {
|
||||||
|
attrs.append(.CenterYWithinMargins)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return attrs
|
return attrs
|
||||||
|
|
Loading…
Reference in New Issue