Skip to content

Instantly share code, notes, and snippets.

@lengocgiang
Created December 3, 2017 09:52
Show Gist options
  • Star 30 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lengocgiang/9a3e1003964c916a0ca7b574db0180e2 to your computer and use it in GitHub Desktop.
Save lengocgiang/9a3e1003964c916a0ca7b574db0180e2 to your computer and use it in GitHub Desktop.
addSubview and removeFromSuperview animation in Swift 4.0
# addSubview
UIView.transition(with: self.view, duration: 0.25, options: [.transitionCrossDissolve], animations: {
self.view.addSubview(view)
}, completion: nil)
# removeFromSuperview
UIView.transition(with: self.view, duration: 0.25, options: [.transitionCrossDissolve], animations: {
subview.removeFromSuperview()
}, completion: nil)
@raditsan
Copy link

hy thanks

@lengocgiang
Copy link
Author

hy thanks

you're welcome, happy coding

@MarjanBasiri
Copy link

Thank you ^_^

@davidrynn
Copy link

Yeah, thanks!

@beta-yu
Copy link

beta-yu commented Jul 23, 2020

Thanks!

@mehdi-S
Copy link

mehdi-S commented Aug 17, 2020

thx a lot !

Copy link

ghost commented Oct 16, 2020

Hi, thanks for this. But can this be used on UITabBarItem subviews that are within ViewControllers? Or how do we make this work on UITabBarItems?

@Cornelius92
Copy link

Cornelius92 commented Nov 16, 2020

Thanks, man!

@erickbrittes
Copy link

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment