美图镇楼
11150073,1366,768.jpg
首先这里使用的是SMSsdk短信验证,如果用其他的更换即可
下面是点击按钮的事件,其中倒计时有点击后的小动画,自己去体会吧
<code>
-(void)SendCodeBut:(UIButton *)button{
if([self.MobileText.text compare:@""]==NSOrderedSame){
UIAlertView *alertV = [[UIAlertView alloc]initWithTitle:@"提示" message:@"手机号码不能为空" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
[alertV show];
</code>
}else if(_MobileText.text.length<11){
<code>
UIAlertView alertV = [[UIAlertView alloc]initWithTitle:@"提示" message:@"手机号码格式有误,请输入正确的号码" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
[alertV show];
</code>
//手机号输入正常,发送验证码并且启动倒计时功能
}else if(_MobileText.text.length==11){
/*
-
@from v1.1.1
-
@brief 获取验证码(Get verification code)
-
@param method 获取验证码的方法(The method of getting verificationCode)
-
@param phoneNumber 电话号码(The phone number)
-
@param zone 区域号,不要加"+"号(Area code)
-
@param result 请求结果回调(Results of the request)
*/
<code>
[SMSSDK getVerificationCodeByMethod:SMSGetCodeMethodSMS phoneNumber:self.MobileText.text zone:@"86" customIdentifier:nil result:^(NSError *error) {
</code>
if (error) {
NSLog(@"sada提交手机成功%@",error);
}else{
NSLog(@"sada提交手机成功");
<code>
__block int timeout=60; //倒计时时间
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_source_t _timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0,queue);
dispatch_source_set_timer(_timer,dispatch_walltime(NULL, 0),1.0*NSEC_PER_SEC, 0); //每秒执行
dispatch_source_set_event_handler(_timer, ^{
if(timeout<=0){ //倒计时结束,关闭
dispatch_source_cancel(_timer);
dispatch_async(dispatch_get_main_queue(), ^{
//设置界面的按钮显示 根据自己需求设置
[_sendCodeButton setTitle:@"发送验证码" forState:UIControlStateNormal];
_sendCodeButton.userInteractionEnabled = YES;
});
}
</code>
else{
<code>
int seconds = timeout % 60;
NSString *strTime = [NSString stringWithFormat:@"%.2d", seconds];
dispatch_async(dispatch_get_main_queue(), ^{
//设置界面的按钮显示 根据自己需求设置
//NSLog(@"____%@",strTime);
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[_sendCodeButton setTitle:[NSString stringWithFormat:@"重新发送(%@)",strTime] forState:UIControlStateNormal];
//文字自适应
[_sendCodeButton sizeToFit];
[UIView commitAnimations];
_sendCodeButton.userInteractionEnabled = NO;
});
timeout--;
}
});
dispatch_resume(_timer);
}
}];
}
}
</code>
福利来啦
性感风
11382286,1366,768.jpg ![ ![11857619,1366,768.jpg](https://img.haomeiwen.com/i1491655/322ff25b7af269e5.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) ](https://img.haomeiwen.com/i1491655/979fe8daac712627.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
清新风
14004029,1366,768.jpg 11454588,1366,768.jpg 14002997,1366,768.jpg 13971598,1366,768.jpg
网友评论