iOS: How does one animate to new autolayout constraint (height)
After updating your constraint: [UIView animateWithDuration:0.5 animations:^{[self.view layoutIfNeeded];}]; Replace self.view with a reference to the containing view.
After updating your constraint: [UIView animateWithDuration:0.5 animations:^{[self.view layoutIfNeeded];}]; Replace self.view with a reference to the containing view.
Here is an NSLayoutConstraint extension in Swift that makes setting a new multiplier pretty easy: In Swift 3.0+ import UIKit extension NSLayoutConstraint { /** Change multiplier constraint – parameter multiplier: CGFloat – returns: NSLayoutConstraint */ func setMultiplier(multiplier:CGFloat) -> NSLayoutConstraint { NSLayoutConstraint.deactivate([self]) let newConstraint = NSLayoutConstraint( item: firstItem, attribute: firstAttribute, relatedBy: relation, toItem: secondItem, attribute: secondAttribute, … Read more
I would suggest the following: Add a height constraint to your collection view. Set its priority to 999. Set its constant to any value that makes it reasonably visible on the storyboard. Change the bottom equal constraint of the collection view to greater or equal. Connect the height constraint to an outlet. Every time you … Read more
I would recommend to debug and find which constraint is “the one you don’t want”. Suppose you have following issue: Always the problem is how to find following Constraints and Views. There are two solutions how to do this: DEBUG VIEW HIERARCHY (Do not recommend this way) Since you know where to find unexpected constraints … Read more
Do you plan to have a squared UIView of width: 100 and Height: 100 centered inside the UIView of an UIViewController? If so, you may try one of the 6 following Auto Layout styles (Swift 5 / iOS 12.2): 1. Using NSLayoutConstraint initializer override func viewDidLoad() { let newView = UIView() newView.backgroundColor = UIColor.red view.addSubview(newView) … Read more