Convert Figma logo to code with AI

Yalantis logoStarWars.iOS

This component implements transition animation to crumble view-controller into tiny pieces.

3,778
360
3,778
5

Top Related Projects

A collection of Swift tips & tricks that I've shared on Twitter

Algorithms and data structures in Swift, with explanations!

A curated list of awesome iOS ecosystem, including Objective-C and Swift Projects

The better way to deal with JSON data in Swift.

40,982

Elegant HTTP Networking in Swift

Quick Overview

StarWars.iOS is a Swift-based iOS application that demonstrates the use of view controller transitions and animations. It showcases a unique Star Wars-themed interface with interactive elements and smooth transitions between different screens.

Pros

  • Demonstrates advanced iOS animations and transitions
  • Provides a visually appealing and engaging user interface
  • Serves as a learning resource for iOS developers interested in custom animations
  • Implements modern Swift programming practices

Cons

  • Limited functionality beyond the demonstration of animations
  • May require updates to maintain compatibility with the latest iOS versions
  • Lacks comprehensive documentation for some of the more complex animations
  • Not actively maintained (last update was several years ago)

Code Examples

  1. Setting up a custom transition:
func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
    transition.transitionMode = .present
    transition.startingPoint = button.center
    transition.circleColor = button.backgroundColor!
    
    return transition
}
  1. Implementing a circular reveal animation:
UIView.animate(withDuration: duration, animations: {
    self.circle.transform = CGAffineTransform.identity.scaledBy(x: scale, y: scale)
    fromVC.view.alpha = 0
    
}, completion: { _ in
    transitionContext.completeTransition(true)
})
  1. Configuring a custom navigation bar:
override func viewDidLoad() {
    super.viewDidLoad()
    
    navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
    navigationController?.navigationBar.shadowImage = UIImage()
    navigationController?.navigationBar.isTranslucent = true
    navigationController?.view.backgroundColor = .clear
}

Getting Started

To use StarWars.iOS in your project:

  1. Clone the repository:

    git clone https://github.com/Yalantis/StarWars.iOS.git
    
  2. Open the Xcode project file.

  3. Build and run the project on your iOS simulator or device.

  4. Explore the codebase to understand how the animations and transitions are implemented.

  5. To integrate specific animations into your own project, copy the relevant view controllers and supporting files, ensuring you maintain the proper file structure and dependencies.

Competitor Comparisons

A collection of Swift tips & tricks that I've shared on Twitter

Pros of SwiftTips

  • Extensive collection of Swift tips and tricks, covering a wide range of topics
  • Regularly updated with new content, keeping up with Swift language evolution
  • Well-organized and easy to navigate through different categories of tips

Cons of SwiftTips

  • Lacks a specific focus or theme, unlike StarWars.iOS which has a clear Star Wars theme
  • No visual components or UI elements, primarily text-based code snippets
  • May be overwhelming for beginners due to the large number of tips

Code Comparison

StarWars.iOS (UI-focused):

override func viewDidLoad() {
    super.viewDidLoad()
    view.addSubview(deathStarView)
    deathStarView.frame = view.bounds
}

SwiftTips (Swift language tips):

extension Array where Element: Equatable {
    func removingDuplicates() -> [Element] {
        return reduce(into: []) { result, element in
            if !result.contains(element) {
                result.append(element)
            }
        }
    }
}

The code comparison highlights the different focus areas of the two repositories. StarWars.iOS emphasizes UI components and visual elements related to the Star Wars theme, while SwiftTips provides concise code snippets demonstrating various Swift language features and best practices.

Algorithms and data structures in Swift, with explanations!

Pros of swift-algorithm-club

  • Comprehensive collection of algorithms and data structures implemented in Swift
  • Educational resource with detailed explanations and examples
  • Actively maintained with regular updates and contributions

Cons of swift-algorithm-club

  • Lacks specific UI components or visual elements
  • Not focused on a particular app or use case
  • May be overwhelming for beginners due to its extensive content

Code Comparison

StarWars.iOS focuses on UI animations and transitions:

func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
    let containerView = transitionContext.containerView
    let toView = transitionContext.view(forKey: .to)!
    containerView.addSubview(toView)
    // ... animation code ...
}

swift-algorithm-club emphasizes algorithm implementations:

func breadthFirstSearch(_ graph: Graph, source: Node) -> [String] {
    var queue = Queue<Node>()
    queue.enqueue(source)
    var nodesExplored = [source.label]
    source.visited = true
    // ... BFS implementation ...
}

The code snippets highlight the different focus areas of each repository, with StarWars.iOS centered on iOS-specific UI animations and swift-algorithm-club demonstrating algorithm implementations in Swift.

A curated list of awesome iOS ecosystem, including Objective-C and Swift Projects

Pros of awesome-ios

  • Comprehensive collection of iOS development resources
  • Regularly updated with new tools, libraries, and frameworks
  • Large community contribution and maintenance

Cons of awesome-ios

  • Not a standalone project or application
  • Requires additional effort to implement individual resources

Code comparison

While a direct code comparison isn't relevant due to the nature of these repositories, here's a brief overview:

StarWars.iOS:

class ViewController: UIViewController {
    @IBOutlet weak var contentView: UIView!
    @IBOutlet weak var button: UIButton!
    // ... (implementation details)
}

awesome-ios:

## Table of Contents

- [Courses](#courses)
- [Newsletters](#newsletters)
- [Animations](#animations)
// ... (list of categories and resources)

StarWars.iOS is a specific iOS animation project, while awesome-ios is a curated list of iOS development resources. StarWars.iOS provides a concrete implementation of a Star Wars-themed animation, whereas awesome-ios serves as a comprehensive reference for various iOS development tools and libraries.

StarWars.iOS is ideal for developers looking to implement a specific animation effect or learn from a complete project. awesome-ios, on the other hand, is better suited for developers seeking a wide range of resources to enhance their iOS development skills and stay updated with the latest tools and libraries in the ecosystem.

The better way to deal with JSON data in Swift.

Pros of SwiftyJSON

  • Focused on JSON parsing and manipulation in Swift
  • Extensive documentation and community support
  • Lightweight and easy to integrate into existing projects

Cons of SwiftyJSON

  • Limited to JSON handling, unlike StarWars.iOS which is a full app demo
  • May require additional libraries for UI components or animations
  • Less visually appealing for developers seeking UI inspiration

Code Comparison

SwiftyJSON:

let json = JSON(data: dataFromNetworking)
if let name = json[0]["name"].string {
    // Do something with name
}

StarWars.iOS:

override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)
    animateStarWars()
}

SwiftyJSON focuses on JSON parsing, while StarWars.iOS demonstrates UI animations and app structure. SwiftyJSON is more suitable for developers working with JSON data in Swift projects, whereas StarWars.iOS serves as a showcase for creating visually appealing iOS applications with custom animations.

SwiftyJSON has broader applicability across various iOS projects dealing with JSON data, while StarWars.iOS is primarily useful as a reference for creating Star Wars-themed or similarly styled applications with complex animations.

40,982

Elegant HTTP Networking in Swift

Pros of Alamofire

  • Widely adopted and well-maintained networking library for iOS and macOS
  • Extensive features including request/response serialization, authentication, and validation
  • Comprehensive documentation and active community support

Cons of Alamofire

  • Larger codebase and potential overhead for simple networking tasks
  • Steeper learning curve for developers new to the library
  • May be overkill for projects with minimal networking requirements

Code Comparison

StarWars.iOS (UI animation example):

func addPulse() {
    let pulse = Pulse(numberOfPulses: Float.infinity, radius: 200, position: center)
    pulse.animationDuration = 1.0
    pulse.backgroundColor = UIColor(red: 0.159, green: 0.822, blue: 0.765, alpha: 1.0).cgColor
    self.layer.insertSublayer(pulse, below: self.layer)
}

Alamofire (network request example):

AF.request("https://api.example.com/data")
    .responseDecodable(of: ResponseType.self) { response in
        switch response.result {
        case .success(let value):
            print("Response: \(value)")
        case .failure(let error):
            print("Error: \(error)")
        }
    }

StarWars.iOS focuses on UI animations and visual effects, while Alamofire specializes in networking tasks. The code examples highlight their different purposes, with StarWars.iOS demonstrating a custom animation and Alamofire showcasing a typical network request with response handling.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

StarWars Animation

Platform License

This component implements transition animation to crumble view-controller into tiny pieces.

Yalantis

Preview

Check this project on dribbble.

Also, read how it was done in our blog

Requirements

  • iOS 8.0+
  • Xcode 8
  • Swift 4

Installing with CocoaPods

use_frameworks!
pod 'StarWars', '~> 2.0'

Usage

At first, import StarWars:

import StarWars

Then just implement class of UIViewControllerTransitioningDelegate that will return our animation form method animationControllerForDismissedController and assign it to transitioningDelegate of viewController that you want to dismiss.

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
    let destination = segue.destinationViewController
    destination.transitioningDelegate = self
}

func animationControllerForDismissedController(dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
    return StarWarsGLAnimator()
}

There are also two things you can customize in the Star Wars animation: duration and sprite sizes. Let’s see how you can do this:

let animator = StarWarsGLAnimator()
animator.duration = 2
animator.spriteWidth = 8

Have fun! :)

Let us know!

We’d be really happy if you sent us links to your projects where you use our component. Just send an email to github@yalantis.com And do let us know if you have any questions or suggestion regarding the animation.

P.S. We’re going to publish more awesomeness wrapped in code and a tutorial on how to make UI for iOS (Android) better than better. Stay tuned!

Version history

  • 1.0 Swift 2.0
  • 2.0 Adds Swift 3.0 support
  • 3.0 Adds Swift 4.0 support
  • 4.0 Adds Swift 5.0 support

License

The MIT License (MIT)

Copyright © 2018 Yalantis

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.