IOS 仿某某擷取驗證碼方式,xib+自動布局實現

來源:互聯網
上載者:User

標籤:pop   原始碼   驗證碼   動畫   介面   

GetCodeViewController

仿某某擷取驗證碼,並驗證方式。提供很多自訂介面,高度自訂。也可以自己更改原始碼,介面用xib檔案,加自動布局實現,直觀易懂。

運行項目,請先cd到該目錄後,pod update一下,即可運行,因為用到了POP動畫庫。用法
  1. 將 項目中 popCodeViewController 整個檔案夾拖到你的項目裡面。
  2. 匯入依賴庫POP動畫庫
  3. 自訂控制器中,匯入GetCodeViewController、PresentingAnimator、DismissingAnimator類
  4. 自訂控制器中,實現以下方法
#pragma mark - GetCodeViewDelegate Method- (NSString *)titleForCodeView {    return [NSString stringWithFormat:@"驗證碼已發送至您手機187*****1234"];}- (NSString *)titleForCodeButton {    return @"擷取驗證碼";}- (NSInteger)timeCode {    return 120;}/** *  可以在這個方法裡面做一些網路請求操作,比如說點擊重新擷取驗證碼, *  成功後調用 [codeVc startTimer],開始倒計時,進行新一輪的驗證碼驗證。 */- (void)getCodeButton:(GetCodeViewController *)codeVc {    [codeVc startTimer];}- (BOOL)isStart {    return NO;}- (void)cancelButton:(GetCodeViewController *)codeVc {    [codeVc dismissViewControllerAnimated:YES completion:nil];}- (void)sureButton:(GetCodeViewController *)codeVc {    NSLog(@"確 定");}#pragma mark - UIViewControllerTransitioningDelegate- (id<UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented                                                                  presentingController:(UIViewController *)presenting                                                                      sourceController:(UIViewController *)source{    return [PresentingAnimator new];}- (id<UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed{    return [DismissingAnimator new];}

5.調用,實現以下代碼即可

    GetCodeViewController *getCodeViewController = [GetCodeViewController new];    getCodeViewController.delegate = self;    getCodeViewController.transitioningDelegate = self;    getCodeViewController.modalPresentationStyle = UIModalPresentationCustom;    [self presentViewController:getCodeViewController                                            animated:YES                                          completion:NULL];
版本

支援iOS7.0及以上。

github地址:https://github.com/804145113/GetCodeViewController

著作權聲明:本文為博主原創文章,未經博主允許不得轉載。

IOS 仿某某擷取驗證碼方式,xib+自動布局實現

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.