intuit/CardParts

Resize button

NWilliamsonWalsh opened this issue · 3 comments

I'm trying to make a button with a border that isnt the same width as the card.
I've tried:

`buttonView.widthAnchor.constraint(equalToConstant: 64.0).isActive = true

it doesn't seem to have any affect.

Hey @NWilliamsonWalsh is there any chance that you aren’t calling the button to LayoutIfNeeded()?

@NWilliamsonWalsh Are you still facing this issue?

@NWilliamsonWalsh , below is the way to do it.

  1. Create a stack view, provide layout Margins for it
  2. Embed the button inside stackedView.

Below is the code

 let stackView = CardPartStackView()
        stackView.margins = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
        stackView.isLayoutMarginsRelativeArrangement = true
        stackView.layoutMargins = UIEdgeInsets(top: 0, left: 63, bottom: 0, right: 62)
        stackView.axis = .vertical
        stackView.distribution = .fill

//Create a button 

        let button = CardPartButtonView()
        button.translatesAutoresizingMaskIntoConstraints = false
        button.setTitle("Test Button", for: UIControl.State.normal)

stackView.addArrangedSubView(button)