@@ -33,16 +33,16 @@ public class SimpleLayoutObject: NSObject {
33
33
}
34
34
35
35
@discardableResult
36
- public func bottom( by target: UIView ? = nil , attribute: NSLayoutAttribute = . bottom, multiplier: CGFloat = 1.0 , _ constant: CGFloat = 0 ) -> SimpleLayoutObject {
36
+ public func bottom( by target: Any ? = nil , attribute: NSLayoutAttribute = . bottom, multiplier: CGFloat = 1.0 , _ constant: CGFloat = 0 ) -> SimpleLayoutObject {
37
37
removeBottom ( )
38
38
39
- let targetView = target != nil ? target! : view. superview
39
+ let targetView = target != nil ? target! : view. superview as Any
40
40
constraints. bottom = NSLayoutConstraint ( item: view, attribute: . bottom, relatedBy: . equal, toItem: targetView, attribute: attribute, multiplier: multiplier, constant: constant)
41
41
constraints. bottom? . isActive = true
42
42
return self
43
43
}
44
44
@discardableResult
45
- public func center( by target: UIView ? = nil , centerX: Bool = true , centerY: Bool = true , x: CGFloat = 0 , y: CGFloat = 0 ) -> SimpleLayoutObject {
45
+ public func center( by target: Any ? = nil , centerX: Bool = true , centerY: Bool = true , x: CGFloat = 0 , y: CGFloat = 0 ) -> SimpleLayoutObject {
46
46
if centerX {
47
47
self . centerX ( by: target, x)
48
48
}
@@ -52,28 +52,28 @@ public class SimpleLayoutObject: NSObject {
52
52
return self
53
53
}
54
54
@discardableResult
55
- public func centerX( by target: UIView ? = nil , multiplier: CGFloat = 1.0 , _ constant: CGFloat = 0 ) -> SimpleLayoutObject {
55
+ public func centerX( by target: Any ? = nil , multiplier: CGFloat = 1.0 , _ constant: CGFloat = 0 ) -> SimpleLayoutObject {
56
56
removeHorizontalConstraints ( )
57
57
58
- let targetView = target != nil ? target! : view. superview
58
+ let targetView = target != nil ? target! : view. superview as Any
59
59
constraints. centerX = NSLayoutConstraint ( item: view, attribute: . centerX, relatedBy: . equal, toItem: targetView, attribute: . centerX, multiplier: multiplier, constant: constant)
60
60
constraints. centerX? . isActive = true
61
61
return self
62
62
}
63
63
@discardableResult
64
- public func centerY( by target: UIView ? = nil , multiplier: CGFloat = 1.0 , _ constant: CGFloat = 0 ) -> SimpleLayoutObject {
64
+ public func centerY( by target: Any ? = nil , multiplier: CGFloat = 1.0 , _ constant: CGFloat = 0 ) -> SimpleLayoutObject {
65
65
removeVerticalConstraints ( )
66
66
67
- let targetView = target != nil ? target! : view. superview
67
+ let targetView = target != nil ? target! : view. superview as Any
68
68
constraints. centerY = NSLayoutConstraint ( item: view, attribute: . centerY, relatedBy: . equal, toItem: targetView, attribute: . centerY, multiplier: multiplier, constant: constant)
69
69
constraints. centerY? . isActive = true
70
70
return self
71
71
}
72
72
@discardableResult
73
- public func trailing( by target: UIView ? = nil , attribute: NSLayoutAttribute = . trailing, relation: NSLayoutRelation = . equal, multiplier: CGFloat = 1.0 , _ constant: CGFloat = 0 ) -> SimpleLayoutObject {
73
+ public func trailing( by target: Any ? = nil , attribute: NSLayoutAttribute = . trailing, relation: NSLayoutRelation = . equal, multiplier: CGFloat = 1.0 , _ constant: CGFloat = 0 ) -> SimpleLayoutObject {
74
74
removeTrailing ( )
75
75
76
- let targetView = target != nil ? target! : view. superview
76
+ let targetView = target != nil ? target! : view. superview as Any
77
77
constraints. trailing = NSLayoutConstraint ( item: view, attribute: . trailing, relatedBy: relation, toItem: targetView, attribute: attribute, multiplier: multiplier, constant: constant)
78
78
constraints. trailing? . isActive = true
79
79
return self
@@ -97,13 +97,13 @@ public class SimpleLayoutObject: NSObject {
97
97
return self
98
98
}
99
99
@discardableResult
100
- public func height( by target: UIView ? = nil , fixed: CGFloat = - 1 , relation: NSLayoutRelation = . equal, attribute: NSLayoutAttribute = . height, multiplier: CGFloat = 1.0 , _ constant: CGFloat = 0 ) -> SimpleLayoutObject {
100
+ public func height( by target: Any ? = nil , fixed: CGFloat = - 1 , relation: NSLayoutRelation = . equal, attribute: NSLayoutAttribute = . height, multiplier: CGFloat = 1.0 , _ constant: CGFloat = 0 ) -> SimpleLayoutObject {
101
101
if let height = constraints. height {
102
102
view. removeConstraint ( height)
103
103
view. superview? . removeConstraint ( height)
104
104
}
105
105
106
- let targetView = target != nil ? target! : view. superview
106
+ let targetView = target != nil ? target! : view. superview as Any
107
107
if fixed > - 1 {
108
108
constraints. height = NSLayoutConstraint ( item: view, attribute: . height, relatedBy: relation, toItem: nil , attribute: . notAnAttribute, multiplier: multiplier, constant: fixed)
109
109
} else {
@@ -113,31 +113,31 @@ public class SimpleLayoutObject: NSObject {
113
113
return self
114
114
}
115
115
@discardableResult
116
- public func leading( by target: UIView ? = nil , attribute: NSLayoutAttribute = . leading, relation: NSLayoutRelation = . equal, multiplier: CGFloat = 1.0 , _ constant: CGFloat = 0 ) -> SimpleLayoutObject {
116
+ public func leading( by target: Any ? = nil , attribute: NSLayoutAttribute = . leading, relation: NSLayoutRelation = . equal, multiplier: CGFloat = 1.0 , _ constant: CGFloat = 0 ) -> SimpleLayoutObject {
117
117
removeLeading ( )
118
118
119
- let targetView = target != nil ? target! : view. superview
119
+ let targetView = target != nil ? target! : view. superview as Any
120
120
constraints. leading = NSLayoutConstraint ( item: view, attribute: . leading, relatedBy: relation, toItem: targetView, attribute: attribute, multiplier: multiplier, constant: constant)
121
121
constraints. leading? . isActive = true
122
122
return self
123
123
}
124
124
@discardableResult
125
- public func top( by target: UIView ? = nil , attribute: NSLayoutAttribute = . top, multiplier: CGFloat = 1.0 , _ constant: CGFloat = 0 ) -> SimpleLayoutObject {
125
+ public func top( by target: Any ? = nil , attribute: NSLayoutAttribute = . top, multiplier: CGFloat = 1.0 , _ constant: CGFloat = 0 ) -> SimpleLayoutObject {
126
126
removeTop ( )
127
127
128
- let targetView = target != nil ? target! : view. superview
128
+ let targetView = target != nil ? target! : view. superview as Any
129
129
constraints. top = NSLayoutConstraint ( item: view, attribute: . top, relatedBy: . equal, toItem: targetView, attribute: attribute, multiplier: multiplier, constant: constant)
130
130
constraints. top? . isActive = true
131
131
return self
132
132
}
133
133
@discardableResult
134
- public func width( by target: UIView ? = nil , fixed: CGFloat = - 1 , relation: NSLayoutRelation = . equal, attribute: NSLayoutAttribute = . width, multiplier: CGFloat = 1.0 , _ constant: CGFloat = 0 ) -> SimpleLayoutObject {
134
+ public func width( by target: Any ? = nil , fixed: CGFloat = - 1 , relation: NSLayoutRelation = . equal, attribute: NSLayoutAttribute = . width, multiplier: CGFloat = 1.0 , _ constant: CGFloat = 0 ) -> SimpleLayoutObject {
135
135
if let width = constraints. width {
136
136
view. removeConstraint ( width)
137
137
view. superview? . removeConstraint ( width)
138
138
}
139
139
140
- let targetView = target != nil ? target! : view. superview
140
+ let targetView = target != nil ? target! : view. superview as Any
141
141
if fixed > - 1 {
142
142
constraints. width = NSLayoutConstraint ( item: view, attribute: . width, relatedBy: relation, toItem: nil , attribute: . notAnAttribute, multiplier: multiplier, constant: fixed)
143
143
} else {
@@ -235,13 +235,13 @@ public struct NSLayoutConstraints {
235
235
public var centerY : NSLayoutConstraint ?
236
236
237
237
public init ( leading: NSLayoutConstraint ? = nil ,
238
- top: NSLayoutConstraint ? = nil ,
239
- trailing: NSLayoutConstraint ? = nil ,
240
- bottom: NSLayoutConstraint ? = nil ,
241
- height: NSLayoutConstraint ? = nil ,
242
- width: NSLayoutConstraint ? = nil ,
243
- centerX: NSLayoutConstraint ? = nil ,
244
- centerY: NSLayoutConstraint ? = nil ) {
238
+ top: NSLayoutConstraint ? = nil ,
239
+ trailing: NSLayoutConstraint ? = nil ,
240
+ bottom: NSLayoutConstraint ? = nil ,
241
+ height: NSLayoutConstraint ? = nil ,
242
+ width: NSLayoutConstraint ? = nil ,
243
+ centerX: NSLayoutConstraint ? = nil ,
244
+ centerY: NSLayoutConstraint ? = nil ) {
245
245
self . leading = leading
246
246
self . top = top
247
247
self . trailing = trailing
0 commit comments