mirror of https://github.com/SnapKit/SnapKit
Merge branch 'develop' of github.com:Masonry/Snap into develop
# Conflicts: # Source/View+Snap.swift
This commit is contained in:
commit
d04d78979e
|
@ -313,7 +313,7 @@ final public class Constraint {
|
||||||
NSException(name: "Cannot Install Constraint", reason: "Already installed on different view.", userInfo: nil).raise()
|
NSException(name: "Cannot Install Constraint", reason: "Already installed on different view.", userInfo: nil).raise()
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
return (self.installedLayoutConstraints?.allObjects as? Array<LayoutConstraint>)!
|
return self.installedLayoutConstraints?.allObjects as! Array<LayoutConstraint>
|
||||||
}
|
}
|
||||||
|
|
||||||
var newLayoutConstraints = Array<LayoutConstraint>()
|
var newLayoutConstraints = Array<LayoutConstraint>()
|
||||||
|
@ -465,9 +465,9 @@ final public class Constraint {
|
||||||
|
|
||||||
private func constrainTo(other: ConstraintItem, relation: ConstraintRelation) -> Constraint {
|
private func constrainTo(other: ConstraintItem, relation: ConstraintRelation) -> Constraint {
|
||||||
if other.attributes != ConstraintAttributes.None {
|
if other.attributes != ConstraintAttributes.None {
|
||||||
var toLayoutAttributes = other.attributes.layoutAttributes
|
let toLayoutAttributes = other.attributes.layoutAttributes
|
||||||
if toLayoutAttributes.count > 1 {
|
if toLayoutAttributes.count > 1 {
|
||||||
var fromLayoutAttributes = self.fromItem.attributes.layoutAttributes
|
let fromLayoutAttributes = self.fromItem.attributes.layoutAttributes
|
||||||
if toLayoutAttributes != fromLayoutAttributes {
|
if toLayoutAttributes != fromLayoutAttributes {
|
||||||
NSException(name: "Invalid Constraint", reason: "Cannot constrain to multiple non identical attributes", userInfo: nil).raise()
|
NSException(name: "Invalid Constraint", reason: "Cannot constrain to multiple non identical attributes", userInfo: nil).raise()
|
||||||
return self
|
return self
|
||||||
|
@ -509,22 +509,22 @@ final public class Constraint {
|
||||||
}
|
}
|
||||||
|
|
||||||
private class func closestCommonSuperviewFromView(fromView: View?, toView: View?) -> View? {
|
private class func closestCommonSuperviewFromView(fromView: View?, toView: View?) -> View? {
|
||||||
var views = NSMutableSet()
|
var views = Set<View>()
|
||||||
var fromView = fromView
|
var fromView = fromView
|
||||||
var toView = toView
|
var toView = toView
|
||||||
do {
|
do {
|
||||||
if let view = toView {
|
if let view = toView {
|
||||||
if views.containsObject(view) {
|
if views.contains(view) {
|
||||||
return view
|
return view
|
||||||
}
|
}
|
||||||
views.addObject(view)
|
views.insert(view)
|
||||||
toView = view.superview
|
toView = view.superview
|
||||||
}
|
}
|
||||||
if let view = fromView {
|
if let view = fromView {
|
||||||
if views.containsObject(view) {
|
if views.contains(view) {
|
||||||
return view
|
return view
|
||||||
}
|
}
|
||||||
views.addObject(view)
|
views.insert(view)
|
||||||
fromView = view.superview
|
fromView = view.superview
|
||||||
}
|
}
|
||||||
} while (fromView != nil || toView != nil)
|
} while (fromView != nil || toView != nil)
|
||||||
|
|
|
@ -41,22 +41,12 @@ final public class ConstraintItem {
|
||||||
internal var attributes: ConstraintAttributes
|
internal var attributes: ConstraintAttributes
|
||||||
|
|
||||||
internal var view: View? {
|
internal var view: View? {
|
||||||
get {
|
return self.object as? View
|
||||||
if let view = self.object as? View {
|
|
||||||
return view
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if os(iOS)
|
#if os(iOS)
|
||||||
internal var layoutSupport: UILayoutSupport? {
|
internal var layoutSupport: UILayoutSupport? {
|
||||||
get {
|
return self.object as? UILayoutSupport
|
||||||
if let layoutSupport = self.object as? UILayoutSupport {
|
|
||||||
return layoutSupport
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,13 +61,13 @@ final public class ConstraintMaker {
|
||||||
return constraint
|
return constraint
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class func prepareConstraints(view: View, block: (make: ConstraintMaker) -> Void) -> Array<Constraint> {
|
internal class func prepareConstraints(view: View, @noescape block: (make: ConstraintMaker) -> Void) -> Array<Constraint> {
|
||||||
let maker = ConstraintMaker(view: view)
|
let maker = ConstraintMaker(view: view)
|
||||||
block(make: maker)
|
block(make: maker)
|
||||||
return maker.constraints
|
return maker.constraints
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class func makeConstraints(view: View, block: (make: ConstraintMaker) -> Void) {
|
internal class func makeConstraints(view: View, @noescape block: (make: ConstraintMaker) -> Void) {
|
||||||
#if os(iOS)
|
#if os(iOS)
|
||||||
view.setTranslatesAutoresizingMaskIntoConstraints(false)
|
view.setTranslatesAutoresizingMaskIntoConstraints(false)
|
||||||
#else
|
#else
|
||||||
|
@ -80,7 +80,7 @@ final public class ConstraintMaker {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class func remakeConstraints(view: View, block: (make: ConstraintMaker) -> Void) {
|
internal class func remakeConstraints(view: View, @noescape block: (make: ConstraintMaker) -> Void) {
|
||||||
#if os(iOS)
|
#if os(iOS)
|
||||||
view.setTranslatesAutoresizingMaskIntoConstraints(false)
|
view.setTranslatesAutoresizingMaskIntoConstraints(false)
|
||||||
#else
|
#else
|
||||||
|
@ -99,7 +99,7 @@ final public class ConstraintMaker {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class func updateConstraints(view: View, block: (make: ConstraintMaker) -> Void) {
|
internal class func updateConstraints(view: View, @noescape block: (make: ConstraintMaker) -> Void) {
|
||||||
#if os(iOS)
|
#if os(iOS)
|
||||||
view.setTranslatesAutoresizingMaskIntoConstraints(false)
|
view.setTranslatesAutoresizingMaskIntoConstraints(false)
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -68,19 +68,19 @@ public extension View {
|
||||||
final public var snp_centerWithinMargins: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.CenterWithinMargins) }
|
final public var snp_centerWithinMargins: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.CenterWithinMargins) }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
final public func snp_prepareConstraints(block: (make: ConstraintMaker) -> Void) -> [Constraint] {
|
final public func snp_prepareConstraints(@noescape block: (make: ConstraintMaker) -> Void) -> [Constraint] {
|
||||||
return ConstraintMaker.prepareConstraints(self, block: block)
|
return ConstraintMaker.prepareConstraints(self, block: block)
|
||||||
}
|
}
|
||||||
|
|
||||||
final public func snp_makeConstraints(block: (make: ConstraintMaker) -> Void) {
|
final public func snp_makeConstraints(@noescape block: (make: ConstraintMaker) -> Void) {
|
||||||
ConstraintMaker.makeConstraints(self, block: block)
|
ConstraintMaker.makeConstraints(self, block: block)
|
||||||
}
|
}
|
||||||
|
|
||||||
final public func snp_updateConstraints(block: (make: ConstraintMaker) -> Void) {
|
final public func snp_updateConstraints(@noescape block: (make: ConstraintMaker) -> Void) {
|
||||||
ConstraintMaker.updateConstraints(self, block: block)
|
ConstraintMaker.updateConstraints(self, block: block)
|
||||||
}
|
}
|
||||||
|
|
||||||
final public func snp_remakeConstraints(block: (make: ConstraintMaker) -> Void) {
|
final public func snp_remakeConstraints(@noescape block: (make: ConstraintMaker) -> Void) {
|
||||||
ConstraintMaker.remakeConstraints(self, block: block)
|
ConstraintMaker.remakeConstraints(self, block: block)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue