UIView Animation Analysis

Source: Internet
Author: User

1 //UIView Animation Analysis2 3 #import "ViewController.h"4 5 @interfaceViewcontroller ()6 7@property (nonatomic,strong) UIView *MyView;8 9 @endTen  One @implementationViewcontroller A  -  -  the //lazy Loading is a Get method ah --(UIView *) myview{ -     if(_myview = =Nil) { -_myview =[[UIView alloc]init]; +_myview.backgroundcolor =[Uicolor Orangecolor]; -_myview.frame = CGRectMake ( -, -, -, -); +     } A     return_myview; at } -  -  -  --(void) Viewdidload { - [Super Viewdidload]; inSelf.myView.center = Cgpointmake (self.view.center.x,0); - [Self.view Addsubview:_myview]; to } +  --(void) Touchesbegan: (nonnull nsset<uitouch *> *) touches withevent: (Nullable uievent *)Event{ the      *NSLog (@"begin"); $[UIView animatewithduration:2.0Delay0.0Usingspringwithdamping:0.5Initialspringvelocity:10.0Options0animations:^{Panax NotoginsengNSLog (@"Start Animation"); -Self.myView.center =Self.view.center; the} completion:^(BOOL finished) { +NSLog (@"Complete the animation"); A     }]; theNSLog (@" Over"); +   - } $ @end

Conclusion:

Block is a C-language pre-prepared code that executes when needed. The animation that the UIView system encapsulates is immediately executed. So after writing the code in the callback, it executes immediately. Start with begin, then start the animation, then asynchronously over, then complete the animation.

UIView Animation Analysis

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.