Giter VIP home page Giter VIP logo

ios-afternoon-project-scatter-and-gather's Introduction

Scatter and Gather Animations

Your project today will animate text and images. Your app will scatter the letters of the word "Lambda" by animating the letters to random locations.

After completing the lesson material and this project, you'll be able to animate a number of UIView and CALayer properties.

Preview the scatter animation

Set up the project

Follow these steps to set up your project skeleton:

  1. Create a new Single View iOS Xcode project
  2. In the "Main.storyboard", embed a view controller in a navigation controller (be sure to set the initial view controller arrow)

Add a Bar Button to the Navigation Bar

These steps enable you to run your animation with a single tap:

  1. Add a bar button item to your view controller's navigation bar (right side).
  2. Name the button "Toggle"
  3. Connect an IBAction to your view controller: toggleButtonPressed(_:).
  4. Create a Bool property variable called isScattered that you can toggle true and false.

You'll animate your views to either scatter them (explore outwards) or gather them together (reset to default position) when the Toggle button is tapped. The boolean variable will help you know what state you're in (scattered or gathered).

Create views

Build the UI elements you want to animate (either programmatically or in Interface Builder).

  1. You need six labels (one for each letter of Lambda)
  2. You need one image view for the Lambda logo. (Look for the logo file in this repo)

Create IBOutlet's for these views in your view controller so they can be animated by your toggleButtonPressed(_:) method.

Animate

Scatter Animation:

  • Fade out your logo image view (the logo should disappear over the length of the animation)
  • Move your letters to random locations (read the random Int API below)
  • Assign them a random background color and text color
  • Use a custom transform to rotate the views (letter.transform = CGAffineTransform(rotationAngle: random_angle)
  • Incorporate as many other custom animations as you like
  • Your animation should take between 2 and 4 seconds

Gather Animation

  • Fade in your logo view (it should gradually reappear as the gather animation runs)
  • Reset all the custom properties you previously assigned to the letters (they should appear as they did at the start of the app)
  • Animate the letters back to their starting positions

Stretch Goals

Here are some stretch goals to investigate:

  • Add 3D transforms to your layers instead of a 2D rotation.
  • Animate shadows onto and away from your views.
  • Add keyframe sequences to perform multiple tasks when scattering your views.
  • Chain together animations
  • Add a UIPanGestureRecognizer to move around the Lambda logo

References

Here are some helpful resources for your project:

ios-afternoon-project-scatter-and-gather's People

Contributors

jcgohlke avatar gipyok avatar paulsolt avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.