---restore content starts---
1.RootViewControler
COPYRIGHT©2016 year Chason. All rights reserved.
//
#import "ViewController.h"
#import "MessageCordView.h"
Phone screen width and height
#define Kscreenwidth [UIScreen mainscreen].bounds.size.width
#define Kscreenheight [UIScreen mainscreen].bounds.size.height
@interface Viewcontroller ()
@end
@implementation Viewcontroller
-(void) Viewdidload {
[Super Viewdidload];
Self.view.backgroundColor = [Uicolor Grouptableviewbackgroundcolor];
Messagecordview *coreview = [[Messagecordview alloc] Initwithframe:cgrectmake (0, $, kscreenwidth,50)];
[Self.view Addsubview:coreview];
}
-(void) didreceivememorywarning {
[Super didreceivememorywarning];
Dispose of any resources the can be recreated.
}
@end
2. Package text verification code with input box
COPYRIGHT©2016 year Chason. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface Messagecordview:uiview
@property (nonatomic, strong) Uitextfield *rechargefield;
@property (nonatomic, strong) UIButton *button;
@property (nonatomic, strong) UILabel *label;
@property (nonatomic, strong) Nstimer *timer;
@end
COPYRIGHT©2016 year Chason. All rights reserved.
//
#import "MessageCordView.h"
#import "MyView.h"
Phone screen width and height
#define Kscreenwidth [UIScreen mainscreen].bounds.size.width
#define Kscreenheight [UIScreen mainscreen].bounds.size.height
static int countdowntime = 60;
@implementation Messagecordview
-(Instancetype) initWithFrame: (CGRect) frame
{
self = [super Initwithframe:frame];
if (self) {
UIView *rechargeview = [[UIView alloc] Initwithframe:cgrectmake (0, 0, Frame.size.width, frame.size.height)];
Rechargeview.backgroundcolor = [Uicolor Whitecolor];
[Self addsubview:rechargeview];
UILabel *rechargemoney = [[UILabel alloc] Initwithframe:cgrectmake (all, ten, frame.size.height-20)];
Rechargemoney.font = [Uifont systemfontofsize:16];
Rechargemoney.textcolor = [Uicolor Graycolor];
Rechargemoney.text = @ "Verification Code";
Rechargemoney.font = [Uifont systemfontofsize:20];
[Rechargeview Addsubview:rechargemoney];
_rechargefield = [[Uitextfield alloc] Initwithframe:cgrectmake (Ten, frame.size.width-230, frame.size.height-20)];
_rechargefield.clearbuttonmode = uitextfieldviewmodewhileediting;
_rechargefield.placeholder = @ "Please enter the verification code";
_rechargefield.borderstyle = Uitextborderstylenone;
[Rechargeview Addsubview:_rechargefield];
_button = [MyView creatbuttonwithframe:cgrectmake (frame.size.width-105, 5, frame.size.height-10) title:@ "Get Verification Code" TA g:1000 Tintcolor:[uicolor Whitecolor] Backgroundcolor:[uicolor colorwithred:18/255.0 green:129/255.0 blue:201/255.0 Alpha:1]];
_button.layer.cornerradius = 10;
_button.font = [Uifont systemfontofsize:14];
[_button addtarget:self Action: @selector (Getverificationcode) forcontrolevents:uicontroleventtouchupinside];
[Rechargeview Addsubview:_button];
}
return self;
}
-(void) Getverificationcode
{
_label = [[UILabel alloc]initwithframe:self.button.bounds];
_timer = [[Nstimer alloc]init];
_timer= [Nstimer scheduledtimerwithtimeinterval:1 target:self selector: @selector (Countdown) Userinfo:nil Repeats:YES ];
[_timer setfiredate:[nsdate Distantpast];
Request the server to send SMS verification code
//......
}
-(void) Countdown
{
countdowntime--;
if (countdowntime<=0| | Countdowntime ==60) {
_label.hidden = YES;
_button.hidden = NO;
_button.userinteractionenabled = YES;
[_timer setfiredate:[nsdate distantfuture];
Countdowntime = 60;
}else{
_label.hidden = NO;
_label.text = [NSString stringwithformat:@ "(%ds) re-acquisition", Countdowntime];
_label.font = [Uifont systemfontofsize:12];
_label.backgroundcolor = [Uicolor colorwithred:18/255.0 green:129/255.0 blue:201/255.0 alpha:1];
_label.layer.cornerradius = 8;
_label.clipstobounds = YES;
_label.textalignment = Nstextalignmentcenter;
_label.textcolor= [Uicolor Whitecolor];
[_button Addsubview:_label];
_button.userinteractionenabled = NO;
}
}
@end
3. Create a Get Verification code button
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface Myview:nsobject
+ (UIButton *) Creatbuttonwithframe: (CGRect) Frame title: (NSString *) title tag: (nsinteger) tag tintcolor: (Uicolor *) Tintcolor backgroundcolor: (Uicolor *) backgroundcolor;
@end
#import "MyView.h"
@implementation MyView
+ (UIButton *) Creatbuttonwithframe: (CGRect) Frame title: (NSString *) title tag: (nsinteger) tag tintcolor: (Uicolor *) Tintcolor backgroundcolor: (Uicolor *) backgroundcolor{
UIButton *button = [UIButton buttonwithtype:uibuttontypecustom];
[Button Settitle:title Forstate:uicontrolstatenormal];
Button.tag = tag;
Button.backgroundcolor = BackgroundColor;
Button.tintcolor= Tintcolor;
Button.frame = frame;
[Button Settitlecolor:tintcolor Forstate:uicontrolstatenormal];
return button;
}
@end
---restore content ends---
iOS Development SMS Verification code package easy to use