ITP 342 Mobile App Dev. Animation

Similar documents
ITP 342 Mobile App Dev. Animation

ITP 342 Mobile App Dev. Animation

ITP 342 Mobile App Dev

ios Mobile Development

Questions. Exams: no. Get by without own Mac? Why ios? ios vs Android restrictions. Selling in App store how hard to publish? Future of Objective-C?

Stanford CS193p. Developing Applications for ios. Spring Stanford CS193p. Spring 2012

ITP 342 Mobile App Dev. Data Types

Stanford CS193p. Developing Applications for ios. Winter CS193p. Winter 2017

ITP 342 Mobile App Dev. Fundamentals

ITP 342 Mobile App Dev. Delegates

Stanford CS193p. Developing Applications for iphone 4, ipod Touch, & ipad Fall Stanford CS193p Fall 2010

Mobile Development Lab 3

Core Animation. Building Animated UI s. Bill Dudney. Gala Factory Software LLC. Bill Dudney Core Animation: Building Animated UI s Slide 1

Advanced ios. CSCI 4448/5448: Object-Oriented Analysis & Design Lecture 20 11/01/2012

Stanford CS193p. Developing Applications for ios Fall Stanford CS193p. Fall 2013

Cisco StadiumVision Mobile API for Apple ios

Mobile Application Development

ITP 342 Mobile App Dev. Unit Testing

Kevin van Vechten Core OS

Monday, 1 November The ios System

ITP 342 Mobile App Dev. Fundamentals

Advanced Cocoa Text Tips and Tricks. Aki Inoue Cocoa Engineer

Contents. iphone Training. Industry Trainers. Classroom Training Online Training ON-DEMAND Training. Read what you need

Praktikum Entwicklung von Mediensystemen mit

CSE 341: Programming Languages

SWIFT! init(title: String) { self.title = title } // required initializer w/ named parameter

Announcements. Today s Topics

View Controller Advancements for ios8

Objectives. Introduce static keyword examine syntax describe common uses

Topics in Mobile Computing

COMP327 Mobile Computing Session:

CS193p Spring 2010 Wednesday, March 31, 2010

XMeeting Graphical User Interface Ivan Guajana SWITCH

App SandBox Directory

Introductory ios Development

E Event-based parser, XML, 180 Extended attributes, URLs, 118 API, 119 command line, 118 description, 118 NSURL category, 119

Praktikum Entwicklung von Mediensystemen mit

ITP 342 Advanced Mobile App Dev. Core Data

Grand Central Dispatch

ITP 342 Mobile App Dev. Unit Testing

ITP 342 Mobile App Dev. Connections

Mobile Application Development

Accustoming Yourself to Objective-C

1 Lexical Considerations

Lexical Considerations

Core Graphics & Animation. ios App Development Fall 2010 Lecture 17

LAMBDA EXPRESSIONS. Summer 2018

CSE 230 Intermediate Programming in C and C++ Functions

BIT Java Programming. Sem 1 Session 2011/12. Chapter 2 JAVA. basic

Midterm I - CSE11 Fall 2013 CLOSED BOOK, CLOSED NOTES 50 minutes, 100 points Total.

JavaScript: Sort of a Big Deal,

Chapter 6 Introduction to Defining Classes

AdFalcon ios SDK Developer's Guide. AdFalcon Mobile Ad Network Product of Noqoush Mobile Media Group

Every language has its own scoping rules. For example, what is the scope of variable j in this Java program?

The Best of Both Worlds: Using UIKit with OpenGL

Java How to Program, 10/e. Copyright by Pearson Education, Inc. All Rights Reserved.

Event Delivery: The Responder Chain

Objective-C Runtime. Cocoa s Jewel in the Crown. NSConference Nicolas

WPF and MVVM Study Guides

ITP 342 Mobile App Development. Data Persistence

Objective-C. Stanford CS193p Fall 2013

OVERVIEW. Why learn ios programming? Share first-hand experience. Identify platform differences. Identify similarities with.net

UNIVERSITY OF TORONTO Faculty of Arts and Science. Midterm Sample Solutions CSC324H1 Duration: 50 minutes Instructor(s): David Liu.

egrapher Language Reference Manual

For your convenience Apress has placed some of the front matter material after the index. Please use the Bookmarks and Contents at a Glance links to

ITP 342 Mobile App Development. Model View Controller

CS111: PROGRAMMING LANGUAGE II

What's New in UIKit Dynamics and Visual Effects Session 229

Exercise: Inventing Language

Mobile App Development. ios Platform

CS193P - Lecture 16. iphone Application Development. Audio APIs Video Playback Displaying Web Content Settings

Introduction to Swift. Dr. Sarah Abraham

JavaScript for C# Programmers Kevin

Science. Computer Science

Apple s new Swift language

EECS168 Exam 3 Review

Cisco StadiumVision Mobile API for Apple ios

Grand Central Dispatch. Sri Teja Basava CSCI 5528: Foundations of Software Engineering Spring 10

The Decaf Language. 1 Lexical considerations

T his article is downloaded from

MELODY. Language Reference Manual. Music Programming Language

Chapter 3 - Simple JavaScript - Programming Basics. Lesson 1 - JavaScript: What is it and what does it look like?

Overview of the Ruby Language. By Ron Haley

Intro to Native ios Development. Dave Koziol Arbormoon Software, Inc.

Building a (Core) Foundation. Rob Napier

Introduction to Programming Using Java (98-388)

Finding Bugs Using Xcode Runtime Tools

User Experience: Windows & Views

COMP327 Mobile Computing Session: Lecture Set 1a - Swift Introduction and the Foundation Framework Part 2

ios Application Development Course Details

Lesson: Web Programming(6) Omid Jafarinezhad Sharif University of Technology

Type Checking While Loops

Custom Drawing & Animation. CS 442: Mobile App Development Michael Saelee

Lexical Considerations

Introduction to Bioinformatics

Array Basics: Outline. Creating and Accessing Arrays. Creating and Accessing Arrays. Arrays (Savitch, Chapter 7)

ITP 342 Mobile App Dev. Table Views

ITP 342 Mobile App Development. Data Persistence

Cisco StadiumVision Mobile SDK Guide for Apple ios and Google Android

Cocoa Touch Best Practices

Transcription:

ITP 342 Mobile App Dev Animation

Core Animation Introduced in Mac OS X Leopard Uses animatable "layers" built on OpenGL UIKit supports Core Animation out of the box Every UIView has a CALayer behind it 2

View Animations UIKit makes basic animation easy Multiple view properties are animatable frame (position and size) transform alpha (transparency) background color 3

Animation Methods UIView has several class methods for animation: animatewithduration: animations:! animatewithduration: animations: completion:! animatewithduration: delay: options: animations: completion:! animatewithduration: delay: usingspringwithdamping: initialspringvelocity: options: animations: completion:! 4

Using Blocks to Animate UIView has various class methods that we can use to animate, but they use blocks. So we need to learn about blocks. A block is a chunk of code that can be executed at some future time. Blocks are functions that are objects. 5

Working with Blocks Blocks are a language-level feature added to C, Objective-C and C++, which allow you to create distinct segments of code that can be passed around to methods or functions as if they were values. Blocks are Objective-C objects, which means they can be added to collections like NSArray or NSDictionary. They also have the ability to capture values from the enclosing scope, making them similar to closures or lambdas in other programming languages. 6

Block Syntax The syntax to define a block literal uses the caret symbol (^), like this: ^{! }! NSLog(@"This is a block");! As with function and method definitions, the braces indicate the start and end of the block. In this example, the block doesn t return any value, and doesn t take any arguments. 7

Declaring a Block You use the ^ operator to declare a block variable and to indicate the beginning of a block literal. The body of the block itself is contained within {}. 8

Pass Blocks as Arguments It s common to pass blocks to functions or methods for invocation elsewhere. Blocks are also used for callbacks, defining the code to be executed when a task completes. You can define the callback behavior at the time you initiate the task. Several methods in the Cocoa frameworks take a block as an argument, typically either to perform an operation on a collection of objects, or to use as a callback after an operation has finished. 9

Block Should Be Last It s best practice to use only one block argument to a method. If the method also needs other non-block arguments, the block should come last: - (void)begintaskwithname: (NSString *) name! completion: (void(^)(void)) callback;! This makes the method call easier to read when specifying the block inline, like this: [self begintaskwithname: @"MyTask"! completion: ^{! NSLog(@"The task is complete");! }! ];! 10

Back to Animation UIView has several class methods for animation: animatewithduration: animations:! animatewithduration: animations: completion:! animatewithduration: delay: options: animations: completion:! animatewithduration: delay: usingspringwithdamping: initialspringvelocity: options: animations: completion:! 11

Animate Animate changes to one or more views using the specified duration. + (void) animatewithduration:! (NSTimeInterval) duration! animations: (void (^)(void)) animations! Parameters duration: The total duration of the animations, measured in seconds. If you specify a negative value or 0, the changes are made without animating them. animations: A block object containing the changes to commit to the views. This is where you programmatically change any animatable properties of the views in your view hierarchy. This block takes no parameters and has no return value. This parameter must not be NULL. 12

Example 1 Animation In the ViewController, create a method that passes in a new name (as a NSString) and fades it in. 13

What we have: Animate The old string disappears and the new string fades in. What we want: We want the old string to fade out first. We need 2 animations First one to fade out old string Second one to fade in new string after the first one finishes 14

Animate Animate changes to one or more views using the specified duration and completion handler. + (void) animatewithduration: (NSTimeInterval)! duration animations: (void (^)(void)) animations! completion:(void (^)(BOOL finished))completion! Parameters duration: The total duration of the animations, measured in seconds. animations: A block object containing the changes to commit to the views. completion: A block object to be executed when the animation sequence ends. This block has no return value and takes a single Boolean argument that indicates whether or not the animations actually finished before the completion handler was called. 15

Example 2 Animations Create a method that fades in the new text. The example in class was the animatestudent: firstname: method. Create a method that fades out the old text of the label. In the completion argument for the animation, call the method that fades in the new text. The example in class was the displaystudent: firstname: method. 16

Example 2 Animations Create a method that fades in the new text.! 17

Example 2 Animations Create a method that fades out the old text of the label. In the completion argument for the animation, call the method that fades in the new text. 18

Example Colors Add code to rotate between 2 colors 19

Resources Apple's Developer Site: https://developer.apple.com/library/ios/ documentation/windowsviews/conceptual/ viewpg_iphoneos/animatingviews/ animatingviews.html https://developer.apple.com/library/ios/ DOCUMENTATION/Cocoa/Conceptual/Blocks/ Articles/00_Introduction.html The Pragmatic Studio's Using Blocks: https://pragmaticstudio.com/blog/2010/7/28/ios4- blocks-1 20