快速集成登录页面

一个可以快速集成的登录页面,通过获取验证码登录,以及登录页面的一个服务条款和隐私条款的跳转!纯代码布局页面,用到了sd_autolayout,以及自己写的几个封装的类。
具体的实现方式直接看demo吧!

Simulator Screen Shot 2016年10月31日 下午3.46.40.png

几个核心的代码块说明一下
一个是验证码倒计时这里

-(void)startTime{
    self.isTimeing = YES;
    __block int timeout = 60; //倒计时时间 60s
    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(), ^{
                //设置界面的按钮显示 根据自己需求设置
                self.isTimeing = NO;
                [VerCode setTitle:@"验证" forState:UIControlStateNormal];
                if (phoneNum.text.length > 0) {
                    [VerCode setBackgroundColor:key_BgColorF6E];
                    VerCode.enabled = YES;
                }
            });
        }else{
            int seconds = timeout % 61;
            NSString *strTime = [NSString stringWithFormat:@"%.2d", seconds];
            dispatch_async(dispatch_get_main_queue(), ^{
                //设置界面的按钮显示 根据自己需求设置
                //NSLog(@"____%@",strTime);
                [UIView beginAnimations:nil context:nil];
                [UIView setAnimationDuration:1];
                [VerCode setTitle:[NSString stringWithFormat:@"%@s",strTime] forState:UIControlStateNormal];
                [UIView commitAnimations];
                VerCode.enabled = NO;
                [VerCode setBackgroundColor:key_BgColorB2];
                if (timeout == 50) {
                    canNotGetYZMLab.userInteractionEnabled = YES;
                    canNotGetYZMLab.textColor = key_BgColorF6E;
                }
                if (phoneNum.text.length == 0) {
                    timeout = 0;
                    passwordNum.text = @"";
                }
            });
            timeout--;
        }
    });
    dispatch_resume(_timer);
}

一个是服务条款和隐私条款的格式

    float tw =[self widthForString:str fontSize:14 andHeight:20];
    tw =([UIScreen mainScreen].bounds.size.width-tw)/2;
    
    NSDictionary* style3 = @{@"body":[UIFont fontWithName:@"HelveticaNeue" size:12.0],
                             @"help":[WPAttributedStyleAction styledActionWithAction:^{
                                 NSLog(@"Help action");
                                 
                                 RemarkViewController *remark = [[RemarkViewController alloc]init];
                                 remark.type =0;
                                 [self.navigationController pushViewController:remark animated:YES];
                             }],
                             @"settings":[WPAttributedStyleAction styledActionWithAction:^{
                                 NSLog(@"Settings action");
                                 
                                 RemarkViewController *remark = [[RemarkViewController alloc]init];
                                 remark.type = 1;
                                 [self.navigationController pushViewController:remark animated:YES];
                             }],
                             @"link": key_BgColorF6E};
    
    baoXian.textAlignment = NSTextAlignmentCenter;
    baoXian.textColor = key_BgColor4D;
    baoXian.attributedText = [@"点击开始使用,即表示您同意<help>服务条款</help>及<settings>隐私条款</settings>" attributedStringWithStyleBook:style3];

demo地址:https://github.com/shaoxionghua/CreatLogion

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 173,242评论 25 708
  • 发现 关注 消息 iOS 第三方库、插件、知名博客总结 作者大灰狼的小绵羊哥哥关注 2017.06.26 09:4...
    肇东周阅读 12,229评论 4 61
  • 体验 严人必须律己,法布施,无畏布施 精进 你不是别人,永远不要妄自评价别人
    若兰ZHOU阅读 194评论 0 0
  • 一个人在街上走累了,索性到了咖啡馆。我找了一个最里面的位置坐下,因为我想找个最安静的角落独处,哪怕只有十分钟。服务...
    莘茹声音疗愈顾问阅读 390评论 -1 2
  • 秋雨在下,铁皮在被敲打 烟草在被点燃 灯光在被熄灭 我感到困难,关于表达 与无法改变的回忆 我想要表达,关于孤独 ...
    但丁路0号阅读 230评论 1 1