Coder Social home page Coder Social logo

flashlight's Introduction

Flashlight

Level 0

Students will build a simple Flashlight app to practice working with IBOutlets, IBActions, and UIControlEvents.

Students who complete this project independently are able to:

  • use, understand, and describe different UIControls available in Cocoa Touch
  • use, understand, and describe UIControlEvents
  • create and use IBOutlets to get access to Storyboard elements in code
  • create and use IBActions to run code on a UIControlEvent

Guide

Flashlight View

Build a view with two states. The first state has a black background and an 'On' button with white text. When the user taps 'On' change the background to white, update the button's title to 'Off', and change the button text color to black. The button should toggle the two states.

  1. Open the ViewController scene in Main.storyboard
  2. Add a UIButton to the view, set the initial title to 'On'
    • note: System buttons animate title changes, which can break the XCTest included in the project. To pass the test, change your UIButton type to Custom, or update the test to adjust for the animation delay.
  3. Set the view's background color to black
  4. Create @IBAction func buttonTapped(sender: AnyObject) in your ViewController class

Flashlight Logic

  1. Create a boolean variable isOn to track whether the flashlight is on or off
  2. Use the buttonTapped IBAction to check the current state of the ViewController and toggle the appropriate parameters
    • ex. If isOn is false, set background color, button title text, and button title color

Black Diamonds

  • Add a UISwipeGestureRecognizer to toggle the flashlight
  • Create a Unit or UITest that verifies gesture recognizer function

Tests

  • Verifies state of an isOn boolean variable
  • Verifies state of background color
  • Verifies state of button text
  • Verifies correct state change after toggle

Contributions

Please refer to CONTRIBUTING.md.

Copyright

© DevMountain LLC, 2015. Unauthorized use and/or duplication of this material without express and written permission from DevMountain, LLC is strictly prohibited. Excerpts and links may be used, provided that full and clear credit is given to DevMountain with appropriate and specific direction to the original content.

flashlight's People

Contributors

calebhicks 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.