Nested UIStackViews Broken Constraints

This is a known problem with hiding nested stack views. There are essentially 3 solutions to this problem: Change the spacing to 0, but then you’ll need to remember the previous spacing value. Call innerStackView.removeFromSuperview(), but then you’ll need to remember where to insert the stack view. Wrap the stack view in a UIView with … Read more

Remove views in UIstackview swift

In Swift 5.4 removeArrangedSubview method removes the provided view from the stack’s arrangedSubviews array. The view’s position and size will no longer be managed by the stack view. However, this method does not remove the provided view from the stack’s subviews array; therefore, the view is still displayed as part of the view hierarchy. To … Read more

How can I create UIStackView with variable spacing between views?

Update For iOS 11, StackViews with Custom Spacing Apple has added the ability to set custom spacing in iOS 11. You simply have to specify the spacing after each arranged subview. Unfortunately you can’t specify spacing before. stackView.setCustomSpacing(10.0, after: firstLabel) stackView.setCustomSpacing(10.0, after: secondLabel) Still way better than using your own views. For iOS 10 and … Read more

UIStackView : Is it really necessary to call both removeFromSuperView and removeArrangedSubview to remove a subview?

No, just call subview.removeFromSuperview() /* Removes a subview from the list of arranged subviews without removing it as a subview of the receiver. To remove the view as a subview, send it -removeFromSuperview as usual; the relevant UIStackView will remove it from its arrangedSubviews list automatically. */ open func removeArrangedSubview(_ view: UIView)

UIStackView “Unable to simultaneously satisfy constraints” on “squished” hidden views

You get this issue because when setting a subview from within UIStackView to hidden, it will first constrain its height to zero in order to animate it out. I was getting the following error: 2015-10-01 11:45:13.732 <redacted>[64455:6368084] Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one … Read more

UIStackView Hide View Animation

Just had the same issue. The fix is adding stackView.layoutIfNeeded() inside the animation block. Where stackView is the container of the items you’re wishing to hide. UIView.animate(withDuration: DiscoverHeaderView.animationDuration, delay: 0.0, usingSpringWithDamping: 0.9, initialSpringVelocity: 1, options: [], animations: { clear.isHidden = hideClear useMyLocation.isHidden = hideLocation stackView.layoutIfNeeded() }, completion: nil) Not sure why this is suddenly an … Read more

How to add leading padding to view added inside an UIStackView

When isLayoutMarginsRelativeArrangement property is true, the stack view will layout its arranged views relative to its layout margins. stackView.layoutMargins = UIEdgeInsets(top: 0, left: 20, bottom: 0, right: 20) stackView.isLayoutMarginsRelativeArrangement = true But it affects all arranged views inside to the stack view. If you want this padding for only one arranged view, you need to … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)