GTEasyLayoutAdaptable
public protocol GTEasyLayoutAdaptable
Layout views, apply constraints and update them easily by using the methods
specified in the GTEasyLayoutAdaptable
protocol. An extension with default
implementation is included for instant usage of the protocol.
-
add(view:to:snapTo:padding:size:)
Default implementationUndocumented
Default Implementation
It adds the given view as a subview to the target view, snapping it to the specified edges and applying spacing on each side as described by the padding parameter value.
All edge values except for the
all
case require the width, the height, or both to have a proper value in thesize
parameter. In case there’s no need to provide them, then just pass a zero size (CGSize.zero
).See the
GTEasyLayout.SnapEdges
enumeration for available values regarding edge snapping. To center a view both horizontally and vertically provide thecenterX_Y
edge along with a valid size for it.Use the
padding
parameter value to add some spacing to each side of the view. If no spacing is necessary, pass a zero edge insets value (UIEdgeInsets.zero
).When using any combination of snap edges which includes horizontal or vertical centering (centerX or centerY), then provide only the
left
andtop
values of thepadding
property,right
andbottom
are disregarded. To add padding to the left set a positive value to theleft
parameter of the edge insets; to add padding to the right set a negative value instead. Accordingly, in vertical axis provide a positive value totop
parameter of the edge insets so the view ispushed
down; give a negative value topush
it up.Note that this method takes into account the safe area of the screen.
Declaration
Swift
func add(view: UIView, to targetView: UIView, snapTo edges: GTEasyLayout.SnapEdges, padding: UIEdgeInsets, size: CGSize)
-
updatePadding(at:ofView:newValue:animationSettings:completion:)
Default implementationUndocumented
Default Implementation
Update the padding at the specified side of the given view by applying a new value. Optionally provide customized animation settings and a completion handler.
Declaration
Swift
func updatePadding(at side: GTEasyLayout.Side, ofView view: UIView, newValue: CGFloat, animationSettings: GTEasyLayout.AnimationSettings?, completion: (() -> Void)?)
-
updateDimension(_:ofView:newValue:animationSettings:completion:)
Default implementationUndocumented
Default Implementation
Update the width or height constraint of the given view to the new value.
Declaration
Swift
func updateDimension(_ dimension: GTEasyLayout.Dimension, ofView view: UIView, newValue: CGFloat, animationSettings: GTEasyLayout.AnimationSettings?, completion: (() -> Void)?)