IOS7 Uikit Dynamics-gravity characteristics Uigravitybehavior

Source: Internet
Author: User
Tags uikit

Continuation of the article

In the iOS7, a lot of new features are actually added. I've seen it before and I've learned some new things. such as the new dynamic characteristics, Textkit graphics and text mixed, as well as their own definition of animation jump and so on. That time is also more busy, no time to tidy up. Now that the project is finished, I intend to learn about the new content at the same time in learning the old things.

First of all, the Uidynamicanimator class, all the simulation behavior of the parent class, this gives me the feeling of the same as the first to ask the text. or feel like adding a gesture or adding a view, detailing down.

Uidynamicbehavior: Simulation Behavior, is the parent of dynamic behavior, the main dynamic behavior class Uigravitybehavior, Uicollisionbehavior, Uiattachmentbehavior, Uisnapbehavior, Uipushbehavior, and Uidynamicitembehavior are inherited from the parent class if you want to know the following: http://www.cocoachina.com/newbie/basic/2013 /0616/6415.html

Gravity characteristics

Here we mainly first talk about the gravity characteristics, first casually said, before someone said three apples changed the world, one to jobs. One gave Turing, and one to Newton.

In junior high school, we were generally exposed to Newton's gravitational acceleration, which is free fall. (did not learn to own Baidu, added), with the help of this class of Uidynamicanimator, can help us to achieve a View object (UIView) can be as high as the falling apples, speed up the move. Create a uidynamicanimator Object First, and then add the created object to the Uidynamicanimator object. Add a property of the gravitational acceleration. It feels the same as joining a gesture.

. h

#import <UIKit/UIKit.h> @interface viewcontroller:uiviewcontroller{    uidynamicanimator * _animator;    Uigravitybehavior * _gravity;} @end

. m

-(void) viewdidload{    [Super Viewdidload];    UIView * Apple = [[UIView alloc] Initwithframe:cgrectmake (40,40, +, +)];    Apple.backgroundcolor = [Uicolor redcolor];    [Self.view addsubview:apple];        _animator = [[Uidynamicanimator alloc] initWithReferenceView:self.view];    _gravity = [[Uigravitybehavior alloc] initwithitems:@[apple];    [_animator addbehavior:_gravity];}

Take a look. Look at the effect.

Click to follow me, a lot of other wonderful content!!

Group number: 336146073

IOS7 Uikit Dynamics-gravity characteristics Uigravitybehavior

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.