NSDesign is animation library that contains ready to use of animation classes. Check out the animations below and Enjoy!
Goal: create A circle transition from one view into another
-
Drag and drop
CircularTransition.swift
into your project. -
Use
UIViewControllerTransitioningDelegate
in your initial ViewController -
Make an object of CircularTransition
-
add these functions to conform the protocol
func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
transition.transitionMode = .present
transition.startingPoint = (buttonSender?.center)!
transition.circleColor = (buttonSender?.backgroundColor)!
return transition
}
func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
transition.transitionMode = .dismiss
transition.startingPoint = (buttonSender?.center)!
transition.circleColor = (buttonSender?.backgroundColor)!
return transition
}
- Go to prepare for segue to set delegate to self:
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "segueID" {
let destinationViewController: DestinationViewController = segue.destination as! DestinationViewController
destinationViewController.transitioningDelegate = self
destinationViewController.modalPresentationStyle = .custom
}
}
- For any reference, your can checkout the sample project:
ViewController.swift
andDestinationViewController.swift
- Drag and drop
SkillLoaderView.swift
- Subclass your view with SkillLoaderView
- Modify the animation as you wish from the storyboard
Contributors are more than welcome. NSDesign accepts any kind of great animation in Swift. Just upload a pull request and add a description on your changes you made.
Feel free to add any issue and feature request to make NSDesign better in the future.