mirror of https://github.com/SnapKit/SnapKit
Added more layout attributes
This commit is contained in:
parent
0a40ba4d78
commit
4032cd4bcf
|
@ -61,9 +61,22 @@ internal struct ConstraintAttributes: RawOptionSetType, BooleanType {
|
|||
internal static var CenterY: ConstraintAttributes { return self(512) }
|
||||
internal static var Baseline: ConstraintAttributes { return self(1024) }
|
||||
|
||||
internal static var FirstBaseline: ConstraintAttributes { return self(2048) }
|
||||
|
||||
internal static var LeftMargin: ConstraintAttributes { return self(4096) }
|
||||
internal static var RightMargin: ConstraintAttributes { return self(8192) }
|
||||
internal static var TopMargin: ConstraintAttributes { return self(16384) }
|
||||
internal static var BottomMargin: ConstraintAttributes { return self(32768) }
|
||||
internal static var LeadingMargin: ConstraintAttributes { return self(65536) }
|
||||
internal static var TrailingMargin: ConstraintAttributes { return self(131072) }
|
||||
internal static var CenterXWithinMargins: ConstraintAttributes { return self(262144) }
|
||||
internal static var CenterYWithinMargins: ConstraintAttributes { return self(524288) }
|
||||
|
||||
internal static var Edges: ConstraintAttributes { return self(15) }
|
||||
internal static var Size: ConstraintAttributes { return self(192) }
|
||||
internal static var Center: ConstraintAttributes { return self(768) }
|
||||
internal static var Margins: ConstraintAttributes { return self(61440) }
|
||||
internal static var CenterWithinMargins: ConstraintAttributes { return self(786432) }
|
||||
|
||||
internal var layoutAttributes:Array<NSLayoutAttribute> {
|
||||
var attrs: Array<NSLayoutAttribute> = []
|
||||
|
@ -100,6 +113,33 @@ internal struct ConstraintAttributes: RawOptionSetType, BooleanType {
|
|||
if (self & ConstraintAttributes.Baseline) {
|
||||
attrs.append(.Baseline)
|
||||
}
|
||||
if (self & ConstraintAttributes.FirstBaseline) {
|
||||
attrs.append(.FirstBaseline)
|
||||
}
|
||||
if (self & ConstraintAttributes.LeftMargin) {
|
||||
attrs.append(.LeftMargin)
|
||||
}
|
||||
if (self & ConstraintAttributes.RightMargin) {
|
||||
attrs.append(.RightMargin)
|
||||
}
|
||||
if (self & ConstraintAttributes.TopMargin) {
|
||||
attrs.append(.TopMargin)
|
||||
}
|
||||
if (self & ConstraintAttributes.BottomMargin) {
|
||||
attrs.append(.BottomMargin)
|
||||
}
|
||||
if (self & ConstraintAttributes.LeadingMargin) {
|
||||
attrs.append(.LeadingMargin)
|
||||
}
|
||||
if (self & ConstraintAttributes.TrailingMargin) {
|
||||
attrs.append(.TrailingMargin)
|
||||
}
|
||||
if (self & ConstraintAttributes.CenterXWithinMargins) {
|
||||
attrs.append(.CenterXWithinMargins)
|
||||
}
|
||||
if (self & ConstraintAttributes.CenterYWithinMargins) {
|
||||
attrs.append(.CenterYWithinMargins)
|
||||
}
|
||||
return attrs
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,10 +42,24 @@ public extension View {
|
|||
public var snp_centerY: ConstraintItem { return ConstraintItem(view: self, attributes: ConstraintAttributes.CenterY) }
|
||||
public var snp_baseline: ConstraintItem { return ConstraintItem(view: self, attributes: ConstraintAttributes.Baseline) }
|
||||
|
||||
public var snp_firstBaseline: ConstraintItem { return ConstraintItem(view: self, attributes: ConstraintAttributes.FirstBaseline) }
|
||||
|
||||
public var snp_leftMargin: ConstraintItem { return ConstraintItem(view: self, attributes: ConstraintAttributes.LeftMargin) }
|
||||
public var snp_rightMargin: ConstraintItem { return ConstraintItem(view: self, attributes: ConstraintAttributes.RightMargin) }
|
||||
public var snp_topMargin: ConstraintItem { return ConstraintItem(view: self, attributes: ConstraintAttributes.TopMargin) }
|
||||
public var snp_bottomMargin: ConstraintItem { return ConstraintItem(view: self, attributes: ConstraintAttributes.BottomMargin) }
|
||||
public var snp_leadingMargin: ConstraintItem { return ConstraintItem(view: self, attributes: ConstraintAttributes.LeadingMargin) }
|
||||
public var snp_trailingMargin: ConstraintItem { return ConstraintItem(view: self, attributes: ConstraintAttributes.TrailingMargin) }
|
||||
public var snp_centerXWithinMargin: ConstraintItem { return ConstraintItem(view: self, attributes: ConstraintAttributes.CenterXWithinMargins) }
|
||||
public var snp_centerYWithinMargin: ConstraintItem { return ConstraintItem(view: self, attributes: ConstraintAttributes.CenterYWithinMargins) }
|
||||
|
||||
public var snp_edges: ConstraintItem { return ConstraintItem(view: self, attributes: ConstraintAttributes.Edges) }
|
||||
public var snp_size: ConstraintItem { return ConstraintItem(view: self, attributes: ConstraintAttributes.Size) }
|
||||
public var snp_center: ConstraintItem { return ConstraintItem(view: self, attributes: ConstraintAttributes.Center) }
|
||||
|
||||
public var snp_margins: ConstraintItem { return ConstraintItem(view: self, attributes: ConstraintAttributes.Margins) }
|
||||
public var snp_centerWithinMargins: ConstraintItem { return ConstraintItem(view: self, attributes: ConstraintAttributes.CenterWithinMargins) }
|
||||
|
||||
public func snp_makeConstraints(block: (maker: ConstraintMaker) -> ()) {
|
||||
ConstraintMaker.makeConstraints(self, block: block)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue