Stanford iOS7 Open Class 7-9 notes and demo demo

Source: Internet
Author: User

This section focuses on iOS drawings, gestures, protocols, blocks, mechanics animations (including gravity, collisions, adsorption, and so on) and the contents of the automatic layout.

First, drawing, gesture

(1) When invoking a custom UIView, you can use the Awakefromnib method to do some initialization work.

(2) commonly used units of measurement required for drawing in iOS:

CGFloat: Floating-point value, as with float;

Cgpoint, Cgsize, CGRect are three structures representing the travel XY coordinates, the size value described by the width height, and the rectangle that is described by the origin coordinates and width height, the units of measure are cgfloat.

(3) The custom UIView implementation file has a DrawRect method that gives us a way to redraw the UIView and update our UIView by overriding this method, But Apple requires developers to use the Setneedsdisplay method to notify the system to call DrawRect for repainting, rather than calling it directly.

(4) iOS provides developers with the Uibezierpath class for constructing drawing graphs, such as lines or curves

(5) Coordinate system Reference when drawing the graph, the origin is in the upper left corner, bounds refers to the frame of the view itself rectangle, frame refers to the view outsourcing rectangle composed of coordinate system, center coordinates refers to the center point of view in the parent view coordinate system in the coordinate value.

(6) Gesture, the system has been the gesture has been encapsulated, can be used directly, two ways to use:

One is to add a gesture to Interface builder, then connect it to the implementation file, and then handle the gesture, further using the process to find out where it might be set up, using the auxiliary window to modify the storyboard and standard single-window modification storyboard, The results of the changes are not synchronized, and finally manually modified again, this need to pay attention to.

Another way is to add directly in the code, in advance (such as in viewdidload) Addgesturerecognizer, indicate gesture response function, implement function method.

(7) For the state of the gesture, first divided into discontinuous gestures and continuous gestures, discontinuous gestures such as tap gesture taps, only a state recognized, representing the moment the touch screen was recognized. For discontinuous gestures, such as pinch-and-zoom gestures pinch, gestures are performed in began, Failed, Changed, and cancelled states. These States are key to implementing gesture processing, and when gestures are already being performed, gestures need to be handled in a changed state, in special cases, such as when a call comes in using gestures, and then enters the cancelled state.

Second, the agreement, Block, mechanical effects animation

(1) Agreement,

(2) Block,

(3) View Toggle animation,

(4) Mechanical effects animation, iOS has also encapsulated a lot of effects, the demo used gravity, collision, adsorption effect, using the following methods:

First create a container uidynamicanimator for animation execution, where Referenceview represents the animation in that view, equivalent to the mechanical reference system in physics.

In describing specific mechanics effects, specifying what kind of behavior,

Specifies the object that performs the animation (the Dropbehavior is the act of combining gravity and collision effects)

Third, automatic layout

Xcode provides a mechanism for automatic layout, for some simple interface, adding some constraints can be processed in different sizes, screen rotation of the interface display effect.

Use automatic layout (constraints already added) before and after Effects:

Demo effect,:http://files.cnblogs.com/colinhou/Dropit.zip

time relationship, the evening again to the notes added modified ...

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.