Advertisement
Guest User

Untitled

a guest
Aug 26th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. import UIKit
  2.  
  3. class ViewController: UIViewController {
  4.  
  5. @IBOutlet weak var stackOutlet: UIStackView!
  6. @IBOutlet weak var buttonOutlet: UIButton!
  7. override func viewDidLoad() {
  8. super.viewDidLoad()
  9. // Do any additional setup after loading the view, typically from a nib.
  10.  
  11. }
  12.  
  13. override func didReceiveMemoryWarning() {
  14. super.didReceiveMemoryWarning()
  15. // Dispose of any resources that can be recreated.
  16. }
  17.  
  18. @IBAction func buttonAction(_ sender: AnyObject) {
  19.  
  20. let newView = UIView(frame: CGRect(x: 0, y: 0, width: 240, height: 128))
  21.  
  22. newView.backgroundColor = UIColor.green
  23. self.stackOutlet.insertArrangedSubview(newView, at: 1)
  24.  
  25. UIView.animate(withDuration: 0.5, delay: 0, options: .curveEaseInOut, animations: {
  26. newView.heightAnchor.constraint(equalToConstant: 128).isActive = true
  27. newView.widthAnchor.constraint(equalToConstant: 240).isActive = true
  28. self.view.layoutIfNeeded()
  29. }, completion:
  30. { finished in
  31. print("OKKK")
  32. })
  33. print(stackOutlet.subviews.count)
  34.  
  35. }
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement