diff --git a/Sources/TGCardViewController/cards/TGPageHeaderView.swift b/Sources/TGCardViewController/cards/TGPageHeaderView.swift index 83a6e74..87136c9 100644 --- a/Sources/TGCardViewController/cards/TGPageHeaderView.swift +++ b/Sources/TGCardViewController/cards/TGPageHeaderView.swift @@ -13,6 +13,9 @@ public class TGPageHeaderView: TGHeaderView { @IBOutlet weak var accessoryWrapperView: UIView! @IBOutlet weak var accessoryWrapperHeightConstraint: NSLayoutConstraint! + @IBOutlet weak var accessoryTrailingConstraint: NSLayoutConstraint! + @IBOutlet weak var buttonTrailingConstraint: NSLayoutConstraint! + static func instantiate() -> TGPageHeaderView { guard let view = TGCardViewController.bundle.loadNibNamed("TGPageHeaderView", owner: nil, options: nil)!.first as? TGPageHeaderView @@ -68,7 +71,17 @@ public class TGPageHeaderView: TGHeaderView { var rightAction: (() -> Void)? { didSet { - rightButton?.isHidden = (rightAction == nil) + if rightAction != nil { + rightButton?.isHidden = false + accessoryTrailingConstraint.priority = .defaultLow + buttonTrailingConstraint.priority = .required + setNeedsUpdateConstraints() + } else { + rightButton?.isHidden = true + accessoryTrailingConstraint.priority = .required + buttonTrailingConstraint.priority = .defaultLow + setNeedsUpdateConstraints() + } } } diff --git a/Sources/TGCardViewController/cards/TGPageHeaderView.xib b/Sources/TGCardViewController/cards/TGPageHeaderView.xib index 145ccf6..0652e1d 100644 --- a/Sources/TGCardViewController/cards/TGPageHeaderView.xib +++ b/Sources/TGCardViewController/cards/TGPageHeaderView.xib @@ -1,9 +1,9 @@ - + - + @@ -14,14 +14,14 @@ - + -