Motion Design for IOS (26)

Source: Internet
Author: User

Now let's get started with our warning box interface, so that it's easy to implement in this demo, it's just a simple picture instead of a plain code interface with a label and a button. Let's start creating this interface.

cgfloat alertdimension = 250   CGRect alertviewframe = CGRectMake (Self.window  .bounds  .size  .width /2 -Alertdimension/2 , Self.window   .size  .height /2 -Alertdimension/2 , Alertdimension, alertdimension) Span class= "hljs-comment";  UIView *alertview = [[UIView alloc] Initwithframe:alertviewframe]  

First, we need to create an UIView object to act as our virtual warning box and set its location to the center of the screen. This is done by dividing the width and height of the full screen by 2 and subtracting the width and height of the warning box. I like to set the frame of an object to its final position after it finishes the animation, and then adjust its size or position by manipulating its Transform property. In this way, when adding an animation, CGRect I can remove the completed action on the transform than the frame that recalculates it. This is also why if I want it to become 1.5 times times more, than animating its entire frame, having to calculate its position and size at the pixel level, I prefer to animate a view's transform.scale with a good, simple addition, and the former is painful. Keep it simple.

It's time to set some key properties.

alertView.backgroundColor = [UIColor colorWithPatternImage:    [UIImage imageNamed:@"alert_box"]];alertView.alpha0.0f;alertView.transform = CGAffineTransformMakeScale(1.21.2);alertView.layer.cornerRadius10;

In this code we have done four things:

    1. Set the BackgroundColor property to a picture, which is the picture I created that looks like a nice, simple view of the warning box.
    2. Set Alpha to 0 so that the warning box is not immediately visible until we want it to animate into.
    3. By CGAffineTransformMakeScale() simply manipulating the scale value in the transform matrix, the function sets its Transform property to make the scale larger.
    4. The fillet is formed by setting the Cornerradius property of the view layer.

Let's add a bit of shading to it to complete the configuration of our warning box.

alertview . Layer  .shadowcolor  = [Uicolor Blackcolor]   Alertview.layer  .shadowoffset  = Cgsizemake (0 , 5 )  Alertview.layer  .shadowopacity  = Span class= "Hljs-number" >0.3  f Alertview.layer  .shadowradius  = Span class= "Hljs-number" >10.0  f [Self.window  Addsubview:alertview]   

If I turn the alpha value back to 1.0 and remove the scaled-up transform and then take a screenshot, that's what it looks like.

Motion Design for IOS (26)

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.