IOS open-source project (3): dareloadactivity reload button Learning

Source: Internet
Author: User
1 Preface

The button can also achieve a similar loading effect. Today we will learn a button control similar to the reload effect.

2. Details

This control uses the cabasicanimation and caanimation classes in the quartzcore framework for animation control and uses the cabasicanimation proxy method. Let's take a look at some of the code below:

Zyreloadactivitybutton. h:

 

# Import <uikit/uikit. h> @ interface zyreloadactivitybutton: uibutton {bool animating;} @ property (nonatomic) cgfloat animationduration; // determines whether it is an animation state-(bool) isanimating; // start animation-(void) startanimating; // stop the animation-(void) stopanimating;-(void) spin; @ end

 

Zyviewcontroller. M:

 

// Button listening event-(void) animate :( zyreloadactivitybutton *) button {// if it is a navigationbaritem button if (Button = navigationbaritem) {[Button spin];} else {// non-navigationbaritem button if ([Button isanimating]) {[Button stopanimating];} else {[Button startanimating] ;}}

 

Running result:


When you click the button in the upper-right corner, it will rotate once and then stop. When you click the button in the center of the screen, it will continue to rotate until you click again and then stop.

3 conclusion

The above is all content and I hope it will help you.

Demo: http://download.csdn.net/detail/u010013695/5460101

 

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.