01-Achieve the zoom and animation effect of the image button (the initial application of block)

Source: Internet
Author: User

1 #import "ViewController.h"2 3 #defineKdelta 604 5 @interfaceViewcontroller ()6 7 @end8 9 @implementationViewcontrollerTen  One #pragmaMark encapsulates the code for the animation effect A- (void) Btnclickwithblock: (void(^) ()) Block - { -     //Implementing animations (progressive changes) the [UIView Beginanimations:nil context:nil]; -[UIView setanimationduration:1.0]; -      - block (); +      - [UIView commitanimations]; + } A  at //Cgaffinetransform Transform - //represents the deformation state of a space (rotation angle, scale) - #pragmaMark reverts to its original state --(ibaction) Reset: (ID) Sender { -      -[Self btnclickwithblock:^{ in_btn.transform =cgaffinetransformidentity; -     }]; to } +  - #pragmaThe left and right rotation of the mark control button the-(ibaction) Rotate: (ID) Sender { *     //tag can be used to distinguish the control $[Self btnclickwithblock:^{Panax Notoginsengcgfloat angle = [Sender tag]==Ten?0-M_pi_4:m_pi_4; -_btn.transform =cgaffinetransformrotate (_btn.transform, angle); the     }]; + } A  the #pragmaMark control buttons Move up and down +-(Ibaction) Run: (ID) Sender { -      $[Self btnclickwithblock:^{ $CGRect ImageFrame =_btn.frame; -Nsinteger tag =[sender tag]; -         Switch(tag) { the              Case 1: -IMAGEFRAME.ORIGIN.Y-=Kdelta;Wuyi                  Break; the              Case 2: -Imageframe.origin.x + =Kdelta; Wu                  Break; -              Case 3: AboutIMAGEFRAME.ORIGIN.Y + =Kdelta; $                  Break; -              Case 4: -Imageframe.origin.x-=Kdelta; -                  Break; A                  +             default: the                  Break; -         } $_btn.frame =ImageFrame; the     }]; the } the  the #pragmaThe zoom of the Mark control button --(ibaction) Zoom: (ID) Sender { in      the[Self btnclickwithblock:^{ theCGFloat scale = [Sender tag]== the?1.2:0.8; About_btn.transform =Cgaffinetransformscale (_btn.transform, scale, scale); the     }]; the } the @end


01-Achieve the zoom and animation effect of the image button (the initial application of block)

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.