diff --git a/VDS/Components/TileContainer/TileContainer.swift b/VDS/Components/TileContainer/TileContainer.swift index ad0951e6..bad144e2 100644 --- a/VDS/Components/TileContainer/TileContainer.swift +++ b/VDS/Components/TileContainer/TileContainer.swift @@ -187,29 +187,40 @@ open class TileContainer: Control { /// Called once when a view is initialized and is used to Setup additional UI or other constants and configurations. open override func setup() { super.setup() + + let layoutGuide = UILayoutGuide() + addLayoutGuide(layoutGuide) + layoutGuide + .pinTop() + .pinLeading() + .pinTrailing(0, .defaultHigh) + .pinBottom(0, .defaultHigh) + addSubview(backgroundImageView) addSubview(containerView) addSubview(highlightView) - - widthConstraint = widthAnchor.constraint(equalToConstant: 0) + + widthConstraint = layoutGuide.widthAnchor.constraint(equalToConstant: 0) + widthConstraint?.priority = .defaultHigh - heightGreaterThanConstraint = heightAnchor.constraint(greaterThanOrEqualToConstant: 44.0) + heightGreaterThanConstraint = layoutGuide.heightAnchor.constraint(greaterThanOrEqualToConstant: 44.0) heightGreaterThanConstraint?.isActive = false - heightConstraint = heightAnchor.constraint(equalToConstant: 0) - - backgroundImageView.pinToSuperView() + heightConstraint = layoutGuide.heightAnchor.constraint(equalToConstant: 0) + heightConstraint?.priority = .defaultHigh + + backgroundImageView.pin(layoutGuide) backgroundImageView.isUserInteractionEnabled = false backgroundImageView.isHidden = true - + containerView.backgroundColor = .clear - containerTopConstraint = containerView.pinTop(anchor: topAnchor, constant: padding.value) - containerBottomConstraint = containerView.pinBottom(anchor: bottomAnchor, constant: padding.value) - containerLeadingConstraint = containerView.pinLeading(anchor: leadingAnchor, constant: padding.value) - containerTrailingConstraint = containerView.pinTrailing(anchor: trailingAnchor, constant: padding.value) + containerTopConstraint = containerView.pinTop(anchor: layoutGuide.topAnchor, constant: padding.value) + containerBottomConstraint = containerView.pinBottom(anchor: layoutGuide.bottomAnchor, constant: padding.value) + containerLeadingConstraint = containerView.pinLeading(anchor: layoutGuide.leadingAnchor, constant: padding.value) + containerTrailingConstraint = containerView.pinTrailing(anchor: layoutGuide.trailingAnchor, constant: padding.value) - highlightView.pinToSuperView() + highlightView.pin(layoutGuide) highlightView.isHidden = true highlightView.backgroundColor = .clear diff --git a/VDS/Protocols/LayoutConstraintable.swift b/VDS/Protocols/LayoutConstraintable.swift index ceededbc..3c05bbc7 100644 --- a/VDS/Protocols/LayoutConstraintable.swift +++ b/VDS/Protocols/LayoutConstraintable.swift @@ -31,19 +31,19 @@ extension LayoutConstraintable { @discardableResult /// Pins each to the all 4 anchor points to a view. /// - Parameters: - /// - view: View that you will be pinned within. + /// - layoutConstrainable: LayoutConstrainable that you will be pinned within. /// - edges: Insets for each side. /// - Returns: Yourself. - public func pin(_ view: UIView, with edges: UIEdgeInsets = UIEdgeInsets.zero) -> Self { - pinLeading(view.leadingAnchor, edges.left) - pinTrailing(view.trailingAnchor, edges.right) - pinTop(view.topAnchor, edges.top) - pinBottom(view.bottomAnchor, edges.bottom) + public func pin(_ layoutConstrainable: LayoutConstraintable, with edges: UIEdgeInsets = UIEdgeInsets.zero) -> Self { + pinLeading(layoutConstrainable.leadingAnchor, edges.left) + pinTrailing(layoutConstrainable.trailingAnchor, edges.right) + pinTop(layoutConstrainable.topAnchor, edges.top) + pinBottom(layoutConstrainable.bottomAnchor, edges.bottom) return self } - + + @discardableResult - /// Pins each to the all 4 anchor points to the view you are set within. /// - Parameter edges: Insets for each side. /// - Returns: Yourself.