Resize button
NWilliamsonWalsh opened this issue · 3 comments
NWilliamsonWalsh commented
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
Hey @NWilliamsonWalsh is there any chance that you aren’t calling the button to LayoutIfNeeded()
?
croossin commented
@NWilliamsonWalsh Are you still facing this issue?
badrinathvm commented
@NWilliamsonWalsh , below is the way to do it.
- Create a stack view, provide layout Margins for it
- 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)