Motion Design for IOS (27)

Source: Internet
Author: User

It's time to add some animations. For the warning box to appear, as I said before, we want the overlay to become translucent from completely transparent (invisible). We also want to add two animations to the warning box: Animate the Opacity from 0.0 to 1.0, and scale from more than 1.0 animations to 1.0. This is what the iOS 7 warning box does, so we're going to imitate it.

First let's deal with two opacity animations (overlay and warning box views), because opacity animations generally do not require any advanced spring action, let's use some simple block-based UIView animations.

// 淡入灰色的封盖层和警告框视图[UIView animateWithDuration:.3 delay:0 options:UIViewAnimationOptionCurveEaseInOut    animations:^{    overlayView.alpha0.3f;    alertView.alpha1.0f;} completion:NULL];

We also animate the opacity of the overlay and the view of the warning box in a block. This is because I want overlays and warning boxes to be presented to the user in the same animation and at the same time, so why not animate them together? I will adjust the duration to slightly less than one-third seconds. I came out this time by trying a lot of time, running animations, and making the right choice for this type of animation. When displaying an important message to the user, such as a warning box, it is better to use a soft animation time so that the actual transition becomes more important. Don't show it too quickly, a slightly slower time will make the information more weight and momentum, and users should be concerned.

Now is the time to scale the animated warning box. This time I really want to use a more advanced spring action to make it more interesting than a simple fade-in animation based on block in the example above. In the standard iOS alert view, Apple did not bounce the warning box, but instead used a slow-fading animation to slowly reach the final value. We will coordinate the damping and stiffness properties of the spring animations to achieve this effect.

Scale-animateinchThe alert viewjnwspringanimation *scale = [Jnwspringanimation animationwithkeypath:@"Transform.scale"];Scale. Damping= -;Scale. Stiffness= -;Scale. Mass=1;Scale. Fromvalue= @(1.2);Scale. Tovalue= @(1.0);[Alertview. LayerAddanimation:scale Forkey:scale. KeyPath];Alertview. Transform= Cgaffinetransformmakescale (1.0,1.0);

The key path to this animation is "Transform.scale" because that's the property we want to manipulate on the layer. Remember the first time we created this UIView and set its Transform property CGAffineTransformMakeScale(1.2, 1.2) ? This is the fromvalue we started with, that is, the current scale size, we want to animate it back to 1.0 of the scale, which is normal size and size.

This is what the animation looks like now.

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 (27)

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.