RefreshLayoutViewController.swift 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. //
  2. // RefreshLayoutViewController.swift
  3. // Demo
  4. //
  5. // Created by IEMacBook01 on 23/05/16.
  6. // Copyright © 2016 Iftekhar. All rights reserved.
  7. //
  8. import UIKit
  9. import IQKeyboardManagerSwift
  10. class RefreshLayoutViewController: UIViewController {
  11. @IBOutlet var textViewHeightConstraint: NSLayoutConstraint!
  12. @IBAction func stepperChanged (_ sender: UIStepper) {
  13. #if swift(>=4.2)
  14. let finalCurve = UIView.AnimationOptions.beginFromCurrentState.union(.init(rawValue: 7))
  15. #else
  16. let finalCurve = UIViewAnimationOptions.beginFromCurrentState.union(.init(rawValue: 7))
  17. #endif
  18. let animationDuration: TimeInterval = 0.3
  19. UIView.animate(withDuration: animationDuration, delay: 0, options: finalCurve, animations: { () -> Void in
  20. self.textViewHeightConstraint.constant = CGFloat(sender.value)
  21. self.view.setNeedsLayout()
  22. self.view.layoutIfNeeded()
  23. }) { (_: Bool) -> Void in}
  24. }
  25. @IBAction func reloadLayoutAction (_ sender: UIButton) {
  26. IQKeyboardManager.shared.reloadLayoutIfNeeded()
  27. }
  28. }