Motion Design for IOS (31)

Source: Internet
Author: User

Create a map animation of Jeff Broderick

Earlier in this guide, I mentioned some great animations that Jeff Broderick designed and published to Dribbble.

As I said, there are some who do not understand animation. First, when the icon for the map is clicked, the app's main interface (including the navigation bar) has an opacity and scale animation that fades into the black background and shrinks a little. At the same time, the map with the opacity and proportions of the animation appears significantly to the front of the interface. The map also moves a little bit above the screen, just like over-animation. The map icon will remain in position.

Before we encode and reproduce Jeff's animation, let's take a look at the final animated effect we created.

We UIImageView re-develop this animation through some simple and UIButton , because they can accurately get the feeling of animation, but in the real map this will be a real scalable map view.

First, let's add a picture representing the app's main interface.

//Add the app's main background image Self.appbackground  = [[Uiimageview alloc] Initwithframe:cgrectmake ( 0 , 20 , Self .bounds  .size  .width , 548 )] Self.appbackground  .image  = [ UIImage imagenamed:@ "APP-BG" ] [Self.window  addsubview:self]  

We have added a picture property for "[email protected]" simple UIImageView . The app is very smart to run, you only write "APP-BG" it will be in the app package's image resources to find "[email protected]". This view is added as a @property of the class so that we can reference it in the subsequent code. This shows how to declare a @porperty.

@property (assignUIImageView *appBackground;

This @property can be defined in the @interface of the. h file of the class, or it can be defined in the @interface block of the. m implementation file to make it private. You can read more about the properties of the program in the Objective-c Guide on the Apple developer site.

Finally, we'll UIImageView add it as a child view of the home screen. This is a quick model, otherwise I will create another UIViewController subclass to load our UI code.

If I build and run, this is what the app looks like right now.

Very good! Now let's add the map, it will be transparent, and will begin with the change. We'll add it immediately after the main app, because we want to add the icon button at the end, so it will make the highest z axis, that is, at the top of the other view.

Add map View Self. Mapview= [[Uiimageview alloc] Initwithframe:cgrectmake (0, +, self. Window. Bounds. Size. Width,458)];Self. Mapview. Image= [UIImage imagenamed:@"Map-arrow"];Self. Mapview. Alpha=0.0F;Self. Mapview. Transform= Cgaffinetransformmaketranslation (0, -);Self. Mapview. Transform= Cgaffinetransformscale (self. Mapview. Transform,1.1,1.1);[Self. WindowAddsubview:self. Mapview];

Want to develop these examples under Swift? This is the code above objective-c in Swift.

Self. Mapview= Uiimageview (Frame:cgrectmake (0, +, self. Window!. Bounds. Size. Width,458)) Self. Mapview!. Image= UIImage (named:"Map-arrow") Self. Mapview!. Alpha=0.0Self. Mapview!. Transform= Cgaffinetransformmaketranslation (0, -) Self. Mapview!. Transform= Cgaffinetransformscale (self. Mapview!. Transform,1.1,1.1) Self. Window!. Addsubview(Self. Mapview!)

The frame of the map view starts in the upper-left corner, but is 62 pixels from the top, which is just a little bit below the map button we want to add. The Picture property is set to "Map-arrow", which is just a map image, and I put it together with an arrow to mimic what Jeff was involved in his animation.

Initially, the view is completely transparent, so the Alpha property is set to 0. There are two transformations added to the view: the first moves the view down by 30 pixels, and the second stretches it from normal to 1.1 times times.

Here's what it looks like now, and I'm looking at the Alpha line so we can see where the map is.

This looks like the exact location of the animation's start.

Finished viewing the integration set: Https://github.com/Cloudox/Motion-Design-for-iOS
All rights reserved: Http://blog.csdn.net/cloudox_

Motion Design for IOS (31)

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.