標籤:pop 原始碼 驗證碼 動畫 介面
GetCodeViewController
仿某某擷取驗證碼,並驗證方式。提供很多自訂介面,高度自訂。也可以自己更改原始碼,介面用xib檔案,加自動布局實現,直觀易懂。
運行項目,請先cd到該目錄後,pod update一下,即可運行,因為用到了POP動畫庫。用法
- 將 項目中 popCodeViewController 整個檔案夾拖到你的項目裡面。
- 匯入依賴庫POP動畫庫
- 自訂控制器中,匯入GetCodeViewController、PresentingAnimator、DismissingAnimator類
- 自訂控制器中,實現以下方法
#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+自動布局實現