intuit / CardParts

A reactive, card-based UI framework built on UIKit for iOS developers.
Other
2.52k stars 225 forks source link

Resize button #147

Closed NWilliamsonWalsh closed 5 years ago

NWilliamsonWalsh commented 5 years ago

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.

Yonodactyl commented 5 years ago

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

croossin commented 5 years ago

@NWilliamsonWalsh Are you still facing this issue?

badrinathvm commented 5 years ago

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