fixed issues with TileContainer

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2023-08-31 11:53:32 -05:00
parent 5d6bba44ba
commit c7393aee84
2 changed files with 31 additions and 20 deletions

View File

@ -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

View File

@ -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.