Skip to content

Instantly share code, notes, and snippets.

@MTattin
Created October 10, 2016 01:51
Show Gist options
  • Save MTattin/5fe1701fff605e5e778e16f30873b6ad to your computer and use it in GitHub Desktop.
Save MTattin/5fe1701fff605e5e778e16f30873b6ad to your computer and use it in GitHub Desktop.
swift3でのUIView.animateの挙動の違いについてのメモ ref: http://qiita.com/MTattin/items/3d541901db4b36e646d1
///
/// アニメーション表示
///
self.constraintBottom.constant = 0
UIView.animate(withDuration: 0.1, animations: { [weak self] in
self?.layoutIfNeeded()
}, completion: nil)
///
/// アニメーション非表示
///
self.constraintBottom.constant = -self.frame.size.height
UIView.animate(withDuration: 0.1, animations: { [weak self] in
self?.layoutIfNeeded()
}, completion: nil)
///
/// アニメーション表示
///
self.constraintBottom.constant = 0
UIView.animate(withDuration: 0.1, animations: { [weak self] in
self?.superview?.layoutIfNeeded()
}, completion: nil)
///
/// アニメーション非表示
///
self.constraintBottom.constant = -self.frame.size.height
UIView.animate(withDuration: 0.1, animations: { [weak self] in
self?.superview?.layoutIfNeeded()
}, completion: nil)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment