Skip to content

Instantly share code, notes, and snippets.

@lengocgiang
Created December 3, 2017 09:52
Show Gist options
  • Select an option

  • Save lengocgiang/9a3e1003964c916a0ca7b574db0180e2 to your computer and use it in GitHub Desktop.

Select an option

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)
@mehdi-S

mehdi-S commented Aug 17, 2020

Copy link
Copy Markdown

thx a lot !

ghost commented Oct 16, 2020

Copy link
Copy Markdown

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

Cornelius92 commented Nov 16, 2020

Copy link
Copy Markdown

Thanks, man!

@erickbrittes

Copy link
Copy Markdown

Thanks.

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