iOS Classic explain the countdown button Jkcountdownbutton use

Source: Internet
Author: User
Tags button type

Author: Loving_ios

Reprint please indicate the source: http://blog.csdn.net/loving_ios/article/details/50786890

Download Countdown button Jkcountdownbutton Code transfer door

Jkcountdownbutton, the implementation of the iOS Countdown button, often used for registration, such as sending verification code when the countdown operation.

Here's how to use it:

Code method Creation:

Jkcountdownbutton *button = [Jkcountdownbutton buttonwithtype:uibuttontypecustom];
Button.frame = CGRectMake (M, M, MB);
[Button settitle:@ "Get Authentication Code" Forstate:uicontrolstatenormal];
Button.backgroundcolor = [Uicolor bluecolor];
[Self.view Addsubview:button];
 
[Button addtouchehandler:^ (Jkcountdownbutton*sender, nsinteger tag) {
    sender.enabled = NO;
 
    [Sender startwithsecond:10.0];
 
    [Sender didchange:^nsstring * (Jkcountdownbutton *countdownbutton,int second) {
        nsstring *title = [NSString stringwithformat:@ "%d seconds remaining", second];
        return title;
    }];
    [Sender didfinished:^nsstring * (Jkcountdownbutton *countdownbutton, int second) {
        countdownbutton.enabled = YES;< C13/>return @ "Click Re-Acquire";
 
    }]
 
;
Create with a drag control: first you want button to inherit Jkcountdownbutton class, type set to Custom
@property (Weak, nonatomic) Iboutlet Jkcountdownbutton *button;
 
-(Ibaction) Countdown: (jkcountdownbutton*) Sender {
sender.enabled = NO;
Button type is set to custom otherwise it will flicker
[sender startwithsecond:10.0];
 
[Sender didchange:^nsstring * (Jkcountdownbutton *countdownbutton,int second) {
    nsstring *title = [NSString stringwithformat:@ "%d seconds remaining", second];
    return title;
}];
[Sender didfinished:^nsstring * (Jkcountdownbutton *countdownbutton, int second) {
    countdownbutton.enabled = YES;< C10/>return @ "Click Re-Acquire";}
 
]

Effect Chart:


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.