@@ -85,7 +85,7 @@ public class SnapManager {
85
85
/// - constants: ConstraintConstants to apply
86
86
/// - Returns: SnapManager holding all the values associated with constraints
87
87
@discardableResult
88
- func snap( to view: UIView ? = nil , constants: SnapConfig ) -> SnapManager {
88
+ public func snap( to view: UIView ? = nil , constants: SnapConfig ) -> SnapManager {
89
89
return snap ( to: view,
90
90
top: constants. top,
91
91
leading: constants. leading,
@@ -97,4 +97,107 @@ public class SnapManager {
97
97
centerY: constants. centerY)
98
98
}
99
99
100
+ /// Apply width anchor between calling view and argument view with specified multiplier
101
+ ///
102
+ /// - Parameters:
103
+ /// - view: UIView to apply constraint with (defaulted to superview if nil)
104
+ /// - multiplier: Multiplier value to apply constraint with (default 1)
105
+ /// - Returns: SnapManager holding all the values associated with constraints
106
+ @discardableResult
107
+ public func snapWidth( to view: UIView ? = nil , multiplier: CGFloat = 1 ) -> SnapManager {
108
+ guard let selfView = selfView else {
109
+ print ( " SnapLayout Error - Cannot apply constraint upon a view that is not retained " )
110
+ return SnapManager ( )
111
+ }
112
+ return selfView. snapWidth ( to: view, multiplier: multiplier)
113
+ }
114
+
115
+ /// Apply height anchor between calling view and argument view with specified multiplier
116
+ ///
117
+ /// - Parameters:
118
+ /// - view: UIView to apply constraint with (defaulted to superview if nil)
119
+ /// - multiplier: Multiplier value to apply constraint with (default 1)
120
+ /// - Returns: SnapManager holding all the values associated with constraints
121
+ @discardableResult
122
+ public func snapHeight( to view: UIView ? = nil , multiplier: CGFloat = 1 ) -> SnapManager {
123
+ guard let selfView = selfView else {
124
+ print ( " SnapLayout Error - Cannot apply constraint upon a view that is not retained " )
125
+ return SnapManager ( )
126
+ }
127
+ return selfView. snapHeight ( to: view, multiplier: multiplier)
128
+ }
129
+
130
+ /// Anchor size by applying width anchor and height anchor
131
+ ///
132
+ /// - Parameter size: CGSize specifying width and height
133
+ /// - Returns: SnapManager holding all the values associated with constraints
134
+ @discardableResult
135
+ public func snapSize( size: CGSize ) -> SnapManager {
136
+ guard let selfView = selfView else {
137
+ print ( " SnapLayout Error - Cannot apply constraint upon a view that is not retained " )
138
+ return SnapManager ( )
139
+ }
140
+ return selfView. snapSize ( size: size)
141
+ }
142
+
143
+ /// Applies necessary constraint to ensure calling view will be leading view and the trailingView is on the trailing side.
144
+ /// Initalizes trailing property of SnapManager
145
+ /// - Parameters:
146
+ /// - trailingView: View who will be shown as the trailingView
147
+ /// - constant: Constant value to apply constraint with (default 0)
148
+ /// - Returns: SnapManager holding all the values associated with constraints
149
+ @discardableResult
150
+ public func snap( trailingView: UIView , constant: CGFloat = 0 ) -> SnapManager {
151
+ guard let selfView = selfView else {
152
+ print ( " SnapLayout Error - Cannot apply constraint upon a view that is not retained " )
153
+ return SnapManager ( )
154
+ }
155
+ return selfView. snap ( trailingView: trailingView, constant: constant)
156
+ }
157
+
158
+ /// Applies necessary constraint to ensure calling view will be trailing and the leadingView is on the leading side.
159
+ /// Initalizes trailing property of SnapManager
160
+ /// - Parameters:
161
+ /// - leadingView: View who will be shown as the leadingView
162
+ /// - constant: Constant value to apply constraint with (default 0)
163
+ /// - Returns: SnapManager holding all the values associated with constraints
164
+ @discardableResult
165
+ public func snap( leadingView: UIView , constant: CGFloat = 0 ) -> SnapManager {
166
+ guard let selfView = selfView else {
167
+ print ( " SnapLayout Error - Cannot apply constraint upon a view that is not retained " )
168
+ return SnapManager ( )
169
+ }
170
+ return selfView. snap ( leadingView: leadingView, constant: constant)
171
+ }
172
+
173
+ /// Applies necessary constraint to ensure calling view will be top view and the bottom view will be bottom view
174
+ /// Initalizes bottom property of SnapManager
175
+ /// - Parameters:
176
+ /// - bottomView: View who will be shown as the bottomView
177
+ /// - constant: Constant value to apply constraint with (default 0)
178
+ /// - Returns: SnapManager holding all the values associated with constraints
179
+ @discardableResult
180
+ public func snap( bottomView: UIView , constant: CGFloat = 0 ) -> SnapManager {
181
+ guard let selfView = selfView else {
182
+ print ( " SnapLayout Error - Cannot apply constraint upon a view that is not retained " )
183
+ return SnapManager ( )
184
+ }
185
+ return selfView. snap ( bottomView: bottomView, constant: constant)
186
+ }
187
+
188
+ /// Applies necessary constraint to ensure calling view will be bottom view and the top view will be top view
189
+ ///
190
+ /// - Parameters:
191
+ /// - topView: View who will be shown as the bottomView
192
+ /// - constant: Constant value to apply constraint with (default 0)
193
+ /// - Returns: SnapManager holding all the values associated with constraints
194
+ @discardableResult
195
+ public func snap( topView: UIView , constant: CGFloat = 0 ) -> SnapManager {
196
+ guard let selfView = selfView else {
197
+ print ( " SnapLayout Error - Cannot apply constraint upon a view that is not retained " )
198
+ return SnapManager ( )
199
+ }
200
+ return selfView. snap ( topView: topView, constant: constant)
201
+ }
202
+
100
203
}
0 commit comments