Scenario:
1. UIViewContainer having one (1) child UIViewController.
2. I'm using a UIStoryboard.
Goal:
To animate the entrance of the child UIViewController's view from the left edge of the container (like a UIActionSheet).
I have initially set the member view to blue.
Problem: I can correctly animate the physical coordinates but not the width constraint (nor any other constraint).
Here's my code:
import UIKit
class HamburgerContainerViewController: UIViewController {
@IBOutlet weak var containerView: UIView!
var memberView: UIView!
override func viewDidLoad() {
super.viewDidLoad()
memberView = containerView!.subviews.first!
}
override func viewDidLayoutSubviews() {
memberView.backgroundColor = UIColor.blue
memberView.frame = CGRect(x: 0, y: 0, width: 100, height: 400)
return
}
@IBAction func DoSomething(_ sender: Any) {
memberView.translatesAutoresizingMaskIntoConstraints = false
UIView.animate(withDuration: 1.0) {
// self.memberView.frame.size.width = 345.0 // ... this works.
self.memberView.widthAnchor.constraint(equalToConstant: 25.0) // ...this makes the view slide somewhere else.
self.view.layoutIfNeeded()
}
}
}
Running my code causes the blue member view to side to the upper left of the screen leaving its UIButton & UILabel in its wake.
FYI: Here's a list of constraints upon the member UIViewController's view: