├── test.gif ├── CustomCodeInput ├── Assets.xcassets │ ├── Contents.json │ └── AppIcon.appiconset │ │ └── Contents.json ├── ViewController.h ├── AppDelegate.h ├── main.m ├── CALayer+Category.h ├── CodeInputView.h ├── CALayer+Category.m ├── ViewController.m ├── Info.plist ├── Base.lproj │ ├── Main.storyboard │ └── LaunchScreen.storyboard ├── AppDelegate.m └── CodeInputView.m ├── CustomCodeInput.xcodeproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ ├── xcuserdata │ │ └── wangxueqi.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist ├── xcuserdata │ └── wangxueqi.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist └── project.pbxproj ├── CustomCodeInputTests ├── Info.plist └── CustomCodeInputTests.m ├── CustomCodeInputUITests ├── Info.plist └── CustomCodeInputUITests.m └── README.md /test.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wuyukobe24/CustomCodeInput/HEAD/test.gif -------------------------------------------------------------------------------- /CustomCodeInput/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /CustomCodeInput.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CustomCodeInput.xcodeproj/project.xcworkspace/xcuserdata/wangxueqi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wuyukobe24/CustomCodeInput/HEAD/CustomCodeInput.xcodeproj/project.xcworkspace/xcuserdata/wangxueqi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /CustomCodeInput/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // CustomCodeInput 4 | // 5 | // Created by WangXueqi on 2018/5/7. 6 | // Copyright © 2018年 JingBei. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /CustomCodeInput.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /CustomCodeInput/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // CustomCodeInput 4 | // 5 | // Created by WangXueqi on 2018/5/7. 6 | // Copyright © 2018年 JingBei. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /CustomCodeInput/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // CustomCodeInput 4 | // 5 | // Created by WangXueqi on 2018/5/7. 6 | // Copyright © 2018年 JingBei. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /CustomCodeInput.xcodeproj/xcuserdata/wangxueqi.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | CustomCodeInput.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /CustomCodeInput/CALayer+Category.h: -------------------------------------------------------------------------------- 1 | // 2 | // CALayer+Category.h 3 | // CustomCodeInput 4 | // 5 | // Created by WangXueqi on 2018/5/7. 6 | // Copyright © 2018年 JingBei. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface CALayer (Category) 13 | + (CALayer *)addSubLayerWithFrame:(CGRect)frame 14 | backgroundColor:(UIColor *)color 15 | backView:(UIView *)baseView; 16 | @end 17 | -------------------------------------------------------------------------------- /CustomCodeInput/CodeInputView.h: -------------------------------------------------------------------------------- 1 | // 2 | // CodeInputView.h 3 | // JDZBorrower 4 | // 5 | // Created by WangXueqi on 2018/4/20. 6 | // Copyright © 2018年 JingBei. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | typedef void(^SelectCodeBlock)(NSString *); 12 | @interface CodeInputView : UIView 13 | @property(nonatomic,copy)SelectCodeBlock CodeBlock; 14 | @property(nonatomic,assign)NSInteger inputNum;//验证码输入个数(4或6个) 15 | - (instancetype)initWithFrame:(CGRect)frame inputType:(NSInteger)inputNum selectCodeBlock:(SelectCodeBlock)CodeBlock; 16 | @end 17 | -------------------------------------------------------------------------------- /CustomCodeInput/CALayer+Category.m: -------------------------------------------------------------------------------- 1 | // 2 | // CALayer+Category.m 3 | // CustomCodeInput 4 | // 5 | // Created by WangXueqi on 2018/5/7. 6 | // Copyright © 2018年 JingBei. All rights reserved. 7 | // 8 | 9 | #import "CALayer+Category.h" 10 | 11 | @implementation CALayer (Category) 12 | + (CALayer *)addSubLayerWithFrame:(CGRect)frame 13 | backgroundColor:(UIColor *)color 14 | backView:(UIView *)baseView 15 | { 16 | CALayer * layer = [[CALayer alloc]init]; 17 | layer.frame = frame; 18 | layer.backgroundColor = [color CGColor]; 19 | [baseView.layer addSublayer:layer]; 20 | return layer; 21 | } 22 | @end 23 | -------------------------------------------------------------------------------- /CustomCodeInputTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /CustomCodeInputUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /CustomCodeInputTests/CustomCodeInputTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // CustomCodeInputTests.m 3 | // CustomCodeInputTests 4 | // 5 | // Created by WangXueqi on 2018/5/7. 6 | // Copyright © 2018年 JingBei. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface CustomCodeInputTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation CustomCodeInputTests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | - (void)tearDown { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample { 28 | // This is an example of a functional test case. 29 | // Use XCTAssert and related functions to verify your tests produce the correct results. 30 | } 31 | 32 | - (void)testPerformanceExample { 33 | // This is an example of a performance test case. 34 | [self measureBlock:^{ 35 | // Put the code you want to measure the time of here. 36 | }]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /CustomCodeInput/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // CustomCodeInput 4 | // 5 | // Created by WangXueqi on 2018/5/7. 6 | // Copyright © 2018年 JingBei. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "CodeInputView.h" 11 | 12 | @interface ViewController () 13 | @property(nonatomic,strong)CodeInputView * codeView; 14 | @end 15 | 16 | @implementation ViewController 17 | 18 | - (void)viewDidLoad { 19 | [super viewDidLoad]; 20 | self.view.backgroundColor = [UIColor whiteColor]; 21 | [self.view addSubview:self.codeView]; 22 | } 23 | 24 | - (CodeInputView *)codeView { 25 | // __weak typeof(self) selfWeak = self; 26 | if (!_codeView) { 27 | _codeView = [[CodeInputView alloc]initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.view.frame), 80) inputType:4 selectCodeBlock:^(NSString * code) { 28 | NSLog(@"code === %@",code); 29 | }]; 30 | _codeView.center = self.view.center; 31 | } 32 | return _codeView; 33 | } 34 | 35 | - (void)didReceiveMemoryWarning { 36 | [super didReceiveMemoryWarning]; 37 | // Dispose of any resources that can be recreated. 38 | } 39 | 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /CustomCodeInputUITests/CustomCodeInputUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // CustomCodeInputUITests.m 3 | // CustomCodeInputUITests 4 | // 5 | // Created by WangXueqi on 2018/5/7. 6 | // Copyright © 2018年 JingBei. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface CustomCodeInputUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation CustomCodeInputUITests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | 22 | // In UI tests it is usually best to stop immediately when a failure occurs. 23 | self.continueAfterFailure = NO; 24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 25 | [[[XCUIApplication alloc] init] launch]; 26 | 27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 28 | } 29 | 30 | - (void)tearDown { 31 | // Put teardown code here. This method is called after the invocation of each test method in the class. 32 | [super tearDown]; 33 | } 34 | 35 | - (void)testExample { 36 | // Use recording to get started writing UI tests. 37 | // Use XCTAssert and related functions to verify your tests produce the correct results. 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /CustomCodeInput/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /CustomCodeInput/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /CustomCodeInput/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /CustomCodeInput/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /CustomCodeInput/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // CustomCodeInput 4 | // 5 | // Created by WangXueqi on 2018/5/7. 6 | // Copyright © 2018年 JingBei. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | 24 | - (void)applicationWillResignActive:(UIApplication *)application { 25 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 26 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 27 | } 28 | 29 | 30 | - (void)applicationDidEnterBackground:(UIApplication *)application { 31 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 33 | } 34 | 35 | 36 | - (void)applicationWillEnterForeground:(UIApplication *)application { 37 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 38 | } 39 | 40 | 41 | - (void)applicationDidBecomeActive:(UIApplication *)application { 42 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 43 | } 44 | 45 | 46 | - (void)applicationWillTerminate:(UIApplication *)application { 47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 48 | } 49 | 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CustomCodeInput 2 | 自定义验证码输入框(4位或6位) 3 | 4 | 效果图: 5 | 6 | ![输入框](https://github.com/wuyukobe24/CustomCodeInput/blob/master/test.gif) 7 | ### 基本思路: 8 | * 自定义输入框视图底部放置一个textView,并设置成透明色,目的是用于点击textView可以弹出数字键盘,并且可以获取到输入的数字。 9 | * 在textView的上面循环(循环的次数根据验证码的位数来决定,如4位或6位)创建一组四个控件,分别是:View、Layer、Label和ShapeLayer,并且Layer、Label和ShapeLayer要添加到View上。Layer是底部放置输入框数字的横线,Label是展示输入的数字,ShapeLayer是闪动的光标。 10 | ``` 11 | - (void)initSubviews { 12 | CGFloat W = CGRectGetWidth(self.frame); 13 | CGFloat H = CGRectGetHeight(self.frame); 14 | CGFloat Padd = (K_Screen_Width-self.inputNum*K_W)/(self.inputNum+1); 15 | [self addSubview:self.textView]; 16 | self.textView.frame = CGRectMake(Padd, 0, W-Padd*2, H); 17 | //默认编辑第一个. 18 | [self beginEdit]; 19 | for (int i = 0; i < _inputNum; i ++) { 20 | UIView *subView = [UIView new]; 21 | subView.frame = CGRectMake(Padd+(K_W+Padd)*i, 0, K_W, H); 22 | subView.userInteractionEnabled = NO; 23 | [self addSubview:subView]; 24 | [CALayer addSubLayerWithFrame:CGRectMake(0, H-2, K_W, 2) backgroundColor:[UIColor lightGrayColor] backView:subView]; 25 | //Label 26 | UILabel *label = [[UILabel alloc]init]; 27 | label.frame = CGRectMake(0, 0, K_W, H); 28 | label.textAlignment = NSTextAlignmentCenter; 29 | label.textColor = [UIColor darkGrayColor]; 30 | label.font = [UIFont systemFontOfSize:38]; 31 | [subView addSubview:label]; 32 | //光标 33 | UIBezierPath *path = [UIBezierPath bezierPathWithRect:CGRectMake(K_W / 2, 15, 2, H - 30)]; 34 | CAShapeLayer *line = [CAShapeLayer layer]; 35 | line.path = path.CGPath; 36 | line.fillColor = [UIColor darkGrayColor].CGColor; 37 | [subView.layer addSublayer:line]; 38 | if (i == 0) { 39 | [line addAnimation:[self opacityAnimation] forKey:@"kOpacityAnimation"]; 40 | //高亮颜色 41 | line.hidden = NO; 42 | }else { 43 | line.hidden = YES; 44 | } 45 | //把光标对象和label对象装进数组 46 | [self.lines addObject:line]; 47 | [self.labels addObject:label]; 48 | } 49 | } 50 | ``` 51 | * 把创建的光标对象ShapeLayer和Label对象装进数组,用于后面在输入框输入数字时切换其显示还是隐藏的属性。 52 | * 在textView的代理方法- (void)textViewDidChange:(UITextView *)textView;中去获取输入框输入的内容,并截取对应的数字放到对应创建的Label上进行显示,而光标则根据当前位置上的Label上文本内容的有无来设置光标的隐藏和显示,即如果该位置Label上无数字,则光标显示出来并闪动,反之则隐藏。 53 | ``` 54 | #pragma mark - UITextViewDelegate 55 | - (void)textViewDidChange:(UITextView *)textView { 56 | NSString *verStr = textView.text; 57 | if (verStr.length > _inputNum) { 58 | textView.text = [textView.text substringToIndex:_inputNum]; 59 | } 60 | //大于等于最大值时, 结束编辑 61 | if (verStr.length >= _inputNum) { 62 | [self endEdit]; 63 | } 64 | if (self.CodeBlock) { 65 | self.CodeBlock(textView.text); 66 | } 67 | for (int i = 0; i < _labels.count; i ++) { 68 | UILabel *bgLabel = _labels[i]; 69 | 70 | if (i < verStr.length) { 71 | [self changeViewLayerIndex:i linesHidden:YES]; 72 | bgLabel.text = [verStr substringWithRange:NSMakeRange(i, 1)]; 73 | }else { 74 | [self changeViewLayerIndex:i linesHidden:i == verStr.length ? NO : YES]; 75 | //textView的text为空的时候 76 | if (!verStr && verStr.length == 0) { 77 | [self changeViewLayerIndex:0 linesHidden:NO]; 78 | } 79 | bgLabel.text = @""; 80 | } 81 | } 82 | } 83 | //光标显示或者隐藏 84 | - (void)changeViewLayerIndex:(NSInteger)index linesHidden:(BOOL)hidden { 85 | CAShapeLayer *line = self.lines[index]; 86 | if (hidden) { 87 | [line removeAnimationForKey:@"kOpacityAnimation"]; 88 | }else{ 89 | [line addAnimation:[self opacityAnimation] forKey:@"kOpacityAnimation"]; 90 | } 91 | [UIView animateWithDuration:0.25 animations:^{ 92 | line.hidden = hidden; 93 | }]; 94 | } 95 | ``` 96 | 光标闪动动画为: 97 | ``` 98 | //闪动动画 99 | - (CABasicAnimation *)opacityAnimation { 100 | CABasicAnimation *opacityAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"]; 101 | opacityAnimation.fromValue = @(1.0); 102 | opacityAnimation.toValue = @(0.0); 103 | opacityAnimation.duration = 0.9; 104 | opacityAnimation.repeatCount = HUGE_VALF; 105 | opacityAnimation.removedOnCompletion = YES; 106 | opacityAnimation.fillMode = kCAFillModeForwards; 107 | opacityAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]; 108 | return opacityAnimation; 109 | } 110 | ``` 111 | -------------------------------------------------------------------------------- /CustomCodeInput/CodeInputView.m: -------------------------------------------------------------------------------- 1 | // 2 | // CodeInputView.m 3 | // JDZBorrower 4 | // 5 | // Created by WangXueqi on 2018/4/20. 6 | // Copyright © 2018年 JingBei. All rights reserved. 7 | // 8 | 9 | #import "CodeInputView.h" 10 | #import "CALayer+Category.h" 11 | 12 | #define K_W 59.5 13 | #define K_Screen_Width [UIScreen mainScreen].bounds.size.width 14 | #define K_Screen_Height [UIScreen mainScreen].bounds.size.height 15 | 16 | @interface CodeInputView() 17 | @property(nonatomic,strong)UITextView * textView; 18 | @property(nonatomic,strong)NSMutableArray * lines; 19 | @property(nonatomic,strong)NSMutableArray * labels; 20 | @end 21 | 22 | @implementation CodeInputView 23 | 24 | - (instancetype)initWithFrame:(CGRect)frame inputType:(NSInteger)inputNum selectCodeBlock:(SelectCodeBlock)CodeBlock { 25 | self = [super initWithFrame:frame]; 26 | if (self) { 27 | self.CodeBlock = CodeBlock; 28 | self.inputNum = inputNum; 29 | [self initSubviews]; 30 | } 31 | return self; 32 | } 33 | 34 | - (void)initSubviews { 35 | CGFloat W = CGRectGetWidth(self.frame); 36 | CGFloat H = CGRectGetHeight(self.frame); 37 | CGFloat Padd = (K_Screen_Width-self.inputNum*K_W)/(self.inputNum+1); 38 | [self addSubview:self.textView]; 39 | self.textView.frame = CGRectMake(Padd, 0, W-Padd*2, H); 40 | //默认编辑第一个. 41 | [self beginEdit]; 42 | for (int i = 0; i < _inputNum; i ++) { 43 | UIView *subView = [UIView new]; 44 | subView.frame = CGRectMake(Padd+(K_W+Padd)*i, 0, K_W, H); 45 | subView.userInteractionEnabled = NO; 46 | [self addSubview:subView]; 47 | [CALayer addSubLayerWithFrame:CGRectMake(0, H-2, K_W, 2) backgroundColor:[UIColor lightGrayColor] backView:subView]; 48 | //Label 49 | UILabel *label = [[UILabel alloc]init]; 50 | label.frame = CGRectMake(0, 0, K_W, H); 51 | label.textAlignment = NSTextAlignmentCenter; 52 | label.textColor = [UIColor darkGrayColor]; 53 | label.font = [UIFont systemFontOfSize:38]; 54 | [subView addSubview:label]; 55 | //光标 56 | UIBezierPath *path = [UIBezierPath bezierPathWithRect:CGRectMake(K_W / 2, 15, 2, H - 30)]; 57 | CAShapeLayer *line = [CAShapeLayer layer]; 58 | line.path = path.CGPath; 59 | line.fillColor = [UIColor darkGrayColor].CGColor; 60 | [subView.layer addSublayer:line]; 61 | if (i == 0) { 62 | [line addAnimation:[self opacityAnimation] forKey:@"kOpacityAnimation"]; 63 | //高亮颜色 64 | line.hidden = NO; 65 | }else { 66 | line.hidden = YES; 67 | } 68 | //把光标对象和label对象装进数组 69 | [self.lines addObject:line]; 70 | [self.labels addObject:label]; 71 | } 72 | } 73 | #pragma mark - UITextViewDelegate 74 | - (void)textViewDidChange:(UITextView *)textView { 75 | NSString *verStr = textView.text; 76 | if (verStr.length > _inputNum) { 77 | textView.text = [textView.text substringToIndex:_inputNum]; 78 | } 79 | //大于等于最大值时, 结束编辑 80 | if (verStr.length >= _inputNum) { 81 | [self endEdit]; 82 | } 83 | if (self.CodeBlock) { 84 | self.CodeBlock(textView.text); 85 | } 86 | for (int i = 0; i < _labels.count; i ++) { 87 | UILabel *bgLabel = _labels[i]; 88 | 89 | if (i < verStr.length) { 90 | [self changeViewLayerIndex:i linesHidden:YES]; 91 | bgLabel.text = [verStr substringWithRange:NSMakeRange(i, 1)]; 92 | }else { 93 | [self changeViewLayerIndex:i linesHidden:i == verStr.length ? NO : YES]; 94 | //textView的text为空的时候 95 | if (!verStr && verStr.length == 0) { 96 | [self changeViewLayerIndex:0 linesHidden:NO]; 97 | } 98 | bgLabel.text = @""; 99 | } 100 | } 101 | } 102 | //设置光标显示隐藏 103 | - (void)changeViewLayerIndex:(NSInteger)index linesHidden:(BOOL)hidden { 104 | CAShapeLayer *line = self.lines[index]; 105 | if (hidden) { 106 | [line removeAnimationForKey:@"kOpacityAnimation"]; 107 | }else{ 108 | [line addAnimation:[self opacityAnimation] forKey:@"kOpacityAnimation"]; 109 | } 110 | [UIView animateWithDuration:0.25 animations:^{ 111 | line.hidden = hidden; 112 | }]; 113 | } 114 | //开始编辑 115 | - (void)beginEdit{ 116 | [self.textView becomeFirstResponder]; 117 | } 118 | //结束编辑 119 | - (void)endEdit{ 120 | [self.textView resignFirstResponder]; 121 | } 122 | //闪动动画 123 | - (CABasicAnimation *)opacityAnimation { 124 | CABasicAnimation *opacityAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"]; 125 | opacityAnimation.fromValue = @(1.0); 126 | opacityAnimation.toValue = @(0.0); 127 | opacityAnimation.duration = 0.9; 128 | opacityAnimation.repeatCount = HUGE_VALF; 129 | opacityAnimation.removedOnCompletion = YES; 130 | opacityAnimation.fillMode = kCAFillModeForwards; 131 | opacityAnimation.timingFunction=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]; 132 | return opacityAnimation; 133 | } 134 | //对象初始化 135 | - (NSMutableArray *)lines { 136 | if (!_lines) { 137 | _lines = [NSMutableArray array]; 138 | } 139 | return _lines; 140 | } 141 | - (NSMutableArray *)labels { 142 | if (!_labels) { 143 | _labels = [NSMutableArray array]; 144 | } 145 | return _labels; 146 | } 147 | - (UITextView *)textView { 148 | if (!_textView) { 149 | _textView = [UITextView new]; 150 | _textView.tintColor = [UIColor clearColor]; 151 | _textView.backgroundColor = [UIColor clearColor]; 152 | _textView.textColor = [UIColor clearColor]; 153 | _textView.delegate = self; 154 | _textView.keyboardType = UIKeyboardTypeNumberPad; 155 | } 156 | return _textView; 157 | } 158 | 159 | @end 160 | -------------------------------------------------------------------------------- /CustomCodeInput.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | F13E86F320A0232D00DD6556 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = F13E86F220A0232D00DD6556 /* AppDelegate.m */; }; 11 | F13E86F620A0232D00DD6556 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F13E86F520A0232D00DD6556 /* ViewController.m */; }; 12 | F13E86F920A0232D00DD6556 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F13E86F720A0232D00DD6556 /* Main.storyboard */; }; 13 | F13E86FB20A0232F00DD6556 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F13E86FA20A0232F00DD6556 /* Assets.xcassets */; }; 14 | F13E86FE20A0232F00DD6556 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F13E86FC20A0232F00DD6556 /* LaunchScreen.storyboard */; }; 15 | F13E870120A0232F00DD6556 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = F13E870020A0232F00DD6556 /* main.m */; }; 16 | F13E870B20A0232F00DD6556 /* CustomCodeInputTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F13E870A20A0232F00DD6556 /* CustomCodeInputTests.m */; }; 17 | F13E871620A0232F00DD6556 /* CustomCodeInputUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = F13E871520A0232F00DD6556 /* CustomCodeInputUITests.m */; }; 18 | F13E872520A0237100DD6556 /* CodeInputView.m in Sources */ = {isa = PBXBuildFile; fileRef = F13E872420A0237100DD6556 /* CodeInputView.m */; }; 19 | F13E872820A0247C00DD6556 /* CALayer+Category.m in Sources */ = {isa = PBXBuildFile; fileRef = F13E872720A0247C00DD6556 /* CALayer+Category.m */; }; 20 | /* End PBXBuildFile section */ 21 | 22 | /* Begin PBXContainerItemProxy section */ 23 | F13E870720A0232F00DD6556 /* PBXContainerItemProxy */ = { 24 | isa = PBXContainerItemProxy; 25 | containerPortal = F13E86E620A0232D00DD6556 /* Project object */; 26 | proxyType = 1; 27 | remoteGlobalIDString = F13E86ED20A0232D00DD6556; 28 | remoteInfo = CustomCodeInput; 29 | }; 30 | F13E871220A0232F00DD6556 /* PBXContainerItemProxy */ = { 31 | isa = PBXContainerItemProxy; 32 | containerPortal = F13E86E620A0232D00DD6556 /* Project object */; 33 | proxyType = 1; 34 | remoteGlobalIDString = F13E86ED20A0232D00DD6556; 35 | remoteInfo = CustomCodeInput; 36 | }; 37 | /* End PBXContainerItemProxy section */ 38 | 39 | /* Begin PBXFileReference section */ 40 | F13E86EE20A0232D00DD6556 /* CustomCodeInput.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CustomCodeInput.app; sourceTree = BUILT_PRODUCTS_DIR; }; 41 | F13E86F120A0232D00DD6556 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 42 | F13E86F220A0232D00DD6556 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 43 | F13E86F420A0232D00DD6556 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 44 | F13E86F520A0232D00DD6556 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 45 | F13E86F820A0232D00DD6556 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 46 | F13E86FA20A0232F00DD6556 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 47 | F13E86FD20A0232F00DD6556 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 48 | F13E86FF20A0232F00DD6556 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 49 | F13E870020A0232F00DD6556 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 50 | F13E870620A0232F00DD6556 /* CustomCodeInputTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CustomCodeInputTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 51 | F13E870A20A0232F00DD6556 /* CustomCodeInputTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CustomCodeInputTests.m; sourceTree = ""; }; 52 | F13E870C20A0232F00DD6556 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 53 | F13E871120A0232F00DD6556 /* CustomCodeInputUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CustomCodeInputUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 54 | F13E871520A0232F00DD6556 /* CustomCodeInputUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CustomCodeInputUITests.m; sourceTree = ""; }; 55 | F13E871720A0232F00DD6556 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 56 | F13E872320A0237100DD6556 /* CodeInputView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CodeInputView.h; sourceTree = ""; }; 57 | F13E872420A0237100DD6556 /* CodeInputView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CodeInputView.m; sourceTree = ""; }; 58 | F13E872620A0247C00DD6556 /* CALayer+Category.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "CALayer+Category.h"; sourceTree = ""; }; 59 | F13E872720A0247C00DD6556 /* CALayer+Category.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "CALayer+Category.m"; sourceTree = ""; }; 60 | /* End PBXFileReference section */ 61 | 62 | /* Begin PBXFrameworksBuildPhase section */ 63 | F13E86EB20A0232D00DD6556 /* Frameworks */ = { 64 | isa = PBXFrameworksBuildPhase; 65 | buildActionMask = 2147483647; 66 | files = ( 67 | ); 68 | runOnlyForDeploymentPostprocessing = 0; 69 | }; 70 | F13E870320A0232F00DD6556 /* Frameworks */ = { 71 | isa = PBXFrameworksBuildPhase; 72 | buildActionMask = 2147483647; 73 | files = ( 74 | ); 75 | runOnlyForDeploymentPostprocessing = 0; 76 | }; 77 | F13E870E20A0232F00DD6556 /* Frameworks */ = { 78 | isa = PBXFrameworksBuildPhase; 79 | buildActionMask = 2147483647; 80 | files = ( 81 | ); 82 | runOnlyForDeploymentPostprocessing = 0; 83 | }; 84 | /* End PBXFrameworksBuildPhase section */ 85 | 86 | /* Begin PBXGroup section */ 87 | F13E86E520A0232D00DD6556 = { 88 | isa = PBXGroup; 89 | children = ( 90 | F13E86F020A0232D00DD6556 /* CustomCodeInput */, 91 | F13E870920A0232F00DD6556 /* CustomCodeInputTests */, 92 | F13E871420A0232F00DD6556 /* CustomCodeInputUITests */, 93 | F13E86EF20A0232D00DD6556 /* Products */, 94 | ); 95 | sourceTree = ""; 96 | }; 97 | F13E86EF20A0232D00DD6556 /* Products */ = { 98 | isa = PBXGroup; 99 | children = ( 100 | F13E86EE20A0232D00DD6556 /* CustomCodeInput.app */, 101 | F13E870620A0232F00DD6556 /* CustomCodeInputTests.xctest */, 102 | F13E871120A0232F00DD6556 /* CustomCodeInputUITests.xctest */, 103 | ); 104 | name = Products; 105 | sourceTree = ""; 106 | }; 107 | F13E86F020A0232D00DD6556 /* CustomCodeInput */ = { 108 | isa = PBXGroup; 109 | children = ( 110 | F13E86F120A0232D00DD6556 /* AppDelegate.h */, 111 | F13E86F220A0232D00DD6556 /* AppDelegate.m */, 112 | F13E86F420A0232D00DD6556 /* ViewController.h */, 113 | F13E86F520A0232D00DD6556 /* ViewController.m */, 114 | F13E872320A0237100DD6556 /* CodeInputView.h */, 115 | F13E872420A0237100DD6556 /* CodeInputView.m */, 116 | F13E872620A0247C00DD6556 /* CALayer+Category.h */, 117 | F13E872720A0247C00DD6556 /* CALayer+Category.m */, 118 | F13E86F720A0232D00DD6556 /* Main.storyboard */, 119 | F13E86FA20A0232F00DD6556 /* Assets.xcassets */, 120 | F13E86FC20A0232F00DD6556 /* LaunchScreen.storyboard */, 121 | F13E86FF20A0232F00DD6556 /* Info.plist */, 122 | F13E870020A0232F00DD6556 /* main.m */, 123 | ); 124 | path = CustomCodeInput; 125 | sourceTree = ""; 126 | }; 127 | F13E870920A0232F00DD6556 /* CustomCodeInputTests */ = { 128 | isa = PBXGroup; 129 | children = ( 130 | F13E870A20A0232F00DD6556 /* CustomCodeInputTests.m */, 131 | F13E870C20A0232F00DD6556 /* Info.plist */, 132 | ); 133 | path = CustomCodeInputTests; 134 | sourceTree = ""; 135 | }; 136 | F13E871420A0232F00DD6556 /* CustomCodeInputUITests */ = { 137 | isa = PBXGroup; 138 | children = ( 139 | F13E871520A0232F00DD6556 /* CustomCodeInputUITests.m */, 140 | F13E871720A0232F00DD6556 /* Info.plist */, 141 | ); 142 | path = CustomCodeInputUITests; 143 | sourceTree = ""; 144 | }; 145 | /* End PBXGroup section */ 146 | 147 | /* Begin PBXNativeTarget section */ 148 | F13E86ED20A0232D00DD6556 /* CustomCodeInput */ = { 149 | isa = PBXNativeTarget; 150 | buildConfigurationList = F13E871A20A0232F00DD6556 /* Build configuration list for PBXNativeTarget "CustomCodeInput" */; 151 | buildPhases = ( 152 | F13E86EA20A0232D00DD6556 /* Sources */, 153 | F13E86EB20A0232D00DD6556 /* Frameworks */, 154 | F13E86EC20A0232D00DD6556 /* Resources */, 155 | ); 156 | buildRules = ( 157 | ); 158 | dependencies = ( 159 | ); 160 | name = CustomCodeInput; 161 | productName = CustomCodeInput; 162 | productReference = F13E86EE20A0232D00DD6556 /* CustomCodeInput.app */; 163 | productType = "com.apple.product-type.application"; 164 | }; 165 | F13E870520A0232F00DD6556 /* CustomCodeInputTests */ = { 166 | isa = PBXNativeTarget; 167 | buildConfigurationList = F13E871D20A0232F00DD6556 /* Build configuration list for PBXNativeTarget "CustomCodeInputTests" */; 168 | buildPhases = ( 169 | F13E870220A0232F00DD6556 /* Sources */, 170 | F13E870320A0232F00DD6556 /* Frameworks */, 171 | F13E870420A0232F00DD6556 /* Resources */, 172 | ); 173 | buildRules = ( 174 | ); 175 | dependencies = ( 176 | F13E870820A0232F00DD6556 /* PBXTargetDependency */, 177 | ); 178 | name = CustomCodeInputTests; 179 | productName = CustomCodeInputTests; 180 | productReference = F13E870620A0232F00DD6556 /* CustomCodeInputTests.xctest */; 181 | productType = "com.apple.product-type.bundle.unit-test"; 182 | }; 183 | F13E871020A0232F00DD6556 /* CustomCodeInputUITests */ = { 184 | isa = PBXNativeTarget; 185 | buildConfigurationList = F13E872020A0232F00DD6556 /* Build configuration list for PBXNativeTarget "CustomCodeInputUITests" */; 186 | buildPhases = ( 187 | F13E870D20A0232F00DD6556 /* Sources */, 188 | F13E870E20A0232F00DD6556 /* Frameworks */, 189 | F13E870F20A0232F00DD6556 /* Resources */, 190 | ); 191 | buildRules = ( 192 | ); 193 | dependencies = ( 194 | F13E871320A0232F00DD6556 /* PBXTargetDependency */, 195 | ); 196 | name = CustomCodeInputUITests; 197 | productName = CustomCodeInputUITests; 198 | productReference = F13E871120A0232F00DD6556 /* CustomCodeInputUITests.xctest */; 199 | productType = "com.apple.product-type.bundle.ui-testing"; 200 | }; 201 | /* End PBXNativeTarget section */ 202 | 203 | /* Begin PBXProject section */ 204 | F13E86E620A0232D00DD6556 /* Project object */ = { 205 | isa = PBXProject; 206 | attributes = { 207 | LastUpgradeCheck = 0930; 208 | ORGANIZATIONNAME = JingBei; 209 | TargetAttributes = { 210 | F13E86ED20A0232D00DD6556 = { 211 | CreatedOnToolsVersion = 9.3; 212 | }; 213 | F13E870520A0232F00DD6556 = { 214 | CreatedOnToolsVersion = 9.3; 215 | TestTargetID = F13E86ED20A0232D00DD6556; 216 | }; 217 | F13E871020A0232F00DD6556 = { 218 | CreatedOnToolsVersion = 9.3; 219 | TestTargetID = F13E86ED20A0232D00DD6556; 220 | }; 221 | }; 222 | }; 223 | buildConfigurationList = F13E86E920A0232D00DD6556 /* Build configuration list for PBXProject "CustomCodeInput" */; 224 | compatibilityVersion = "Xcode 9.3"; 225 | developmentRegion = en; 226 | hasScannedForEncodings = 0; 227 | knownRegions = ( 228 | en, 229 | Base, 230 | ); 231 | mainGroup = F13E86E520A0232D00DD6556; 232 | productRefGroup = F13E86EF20A0232D00DD6556 /* Products */; 233 | projectDirPath = ""; 234 | projectRoot = ""; 235 | targets = ( 236 | F13E86ED20A0232D00DD6556 /* CustomCodeInput */, 237 | F13E870520A0232F00DD6556 /* CustomCodeInputTests */, 238 | F13E871020A0232F00DD6556 /* CustomCodeInputUITests */, 239 | ); 240 | }; 241 | /* End PBXProject section */ 242 | 243 | /* Begin PBXResourcesBuildPhase section */ 244 | F13E86EC20A0232D00DD6556 /* Resources */ = { 245 | isa = PBXResourcesBuildPhase; 246 | buildActionMask = 2147483647; 247 | files = ( 248 | F13E86FE20A0232F00DD6556 /* LaunchScreen.storyboard in Resources */, 249 | F13E86FB20A0232F00DD6556 /* Assets.xcassets in Resources */, 250 | F13E86F920A0232D00DD6556 /* Main.storyboard in Resources */, 251 | ); 252 | runOnlyForDeploymentPostprocessing = 0; 253 | }; 254 | F13E870420A0232F00DD6556 /* Resources */ = { 255 | isa = PBXResourcesBuildPhase; 256 | buildActionMask = 2147483647; 257 | files = ( 258 | ); 259 | runOnlyForDeploymentPostprocessing = 0; 260 | }; 261 | F13E870F20A0232F00DD6556 /* Resources */ = { 262 | isa = PBXResourcesBuildPhase; 263 | buildActionMask = 2147483647; 264 | files = ( 265 | ); 266 | runOnlyForDeploymentPostprocessing = 0; 267 | }; 268 | /* End PBXResourcesBuildPhase section */ 269 | 270 | /* Begin PBXSourcesBuildPhase section */ 271 | F13E86EA20A0232D00DD6556 /* Sources */ = { 272 | isa = PBXSourcesBuildPhase; 273 | buildActionMask = 2147483647; 274 | files = ( 275 | F13E872520A0237100DD6556 /* CodeInputView.m in Sources */, 276 | F13E872820A0247C00DD6556 /* CALayer+Category.m in Sources */, 277 | F13E86F620A0232D00DD6556 /* ViewController.m in Sources */, 278 | F13E870120A0232F00DD6556 /* main.m in Sources */, 279 | F13E86F320A0232D00DD6556 /* AppDelegate.m in Sources */, 280 | ); 281 | runOnlyForDeploymentPostprocessing = 0; 282 | }; 283 | F13E870220A0232F00DD6556 /* Sources */ = { 284 | isa = PBXSourcesBuildPhase; 285 | buildActionMask = 2147483647; 286 | files = ( 287 | F13E870B20A0232F00DD6556 /* CustomCodeInputTests.m in Sources */, 288 | ); 289 | runOnlyForDeploymentPostprocessing = 0; 290 | }; 291 | F13E870D20A0232F00DD6556 /* Sources */ = { 292 | isa = PBXSourcesBuildPhase; 293 | buildActionMask = 2147483647; 294 | files = ( 295 | F13E871620A0232F00DD6556 /* CustomCodeInputUITests.m in Sources */, 296 | ); 297 | runOnlyForDeploymentPostprocessing = 0; 298 | }; 299 | /* End PBXSourcesBuildPhase section */ 300 | 301 | /* Begin PBXTargetDependency section */ 302 | F13E870820A0232F00DD6556 /* PBXTargetDependency */ = { 303 | isa = PBXTargetDependency; 304 | target = F13E86ED20A0232D00DD6556 /* CustomCodeInput */; 305 | targetProxy = F13E870720A0232F00DD6556 /* PBXContainerItemProxy */; 306 | }; 307 | F13E871320A0232F00DD6556 /* PBXTargetDependency */ = { 308 | isa = PBXTargetDependency; 309 | target = F13E86ED20A0232D00DD6556 /* CustomCodeInput */; 310 | targetProxy = F13E871220A0232F00DD6556 /* PBXContainerItemProxy */; 311 | }; 312 | /* End PBXTargetDependency section */ 313 | 314 | /* Begin PBXVariantGroup section */ 315 | F13E86F720A0232D00DD6556 /* Main.storyboard */ = { 316 | isa = PBXVariantGroup; 317 | children = ( 318 | F13E86F820A0232D00DD6556 /* Base */, 319 | ); 320 | name = Main.storyboard; 321 | sourceTree = ""; 322 | }; 323 | F13E86FC20A0232F00DD6556 /* LaunchScreen.storyboard */ = { 324 | isa = PBXVariantGroup; 325 | children = ( 326 | F13E86FD20A0232F00DD6556 /* Base */, 327 | ); 328 | name = LaunchScreen.storyboard; 329 | sourceTree = ""; 330 | }; 331 | /* End PBXVariantGroup section */ 332 | 333 | /* Begin XCBuildConfiguration section */ 334 | F13E871820A0232F00DD6556 /* Debug */ = { 335 | isa = XCBuildConfiguration; 336 | buildSettings = { 337 | ALWAYS_SEARCH_USER_PATHS = NO; 338 | CLANG_ANALYZER_NONNULL = YES; 339 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 340 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 341 | CLANG_CXX_LIBRARY = "libc++"; 342 | CLANG_ENABLE_MODULES = YES; 343 | CLANG_ENABLE_OBJC_ARC = YES; 344 | CLANG_ENABLE_OBJC_WEAK = YES; 345 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 346 | CLANG_WARN_BOOL_CONVERSION = YES; 347 | CLANG_WARN_COMMA = YES; 348 | CLANG_WARN_CONSTANT_CONVERSION = YES; 349 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 350 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 351 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 352 | CLANG_WARN_EMPTY_BODY = YES; 353 | CLANG_WARN_ENUM_CONVERSION = YES; 354 | CLANG_WARN_INFINITE_RECURSION = YES; 355 | CLANG_WARN_INT_CONVERSION = YES; 356 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 357 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 358 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 359 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 360 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 361 | CLANG_WARN_STRICT_PROTOTYPES = YES; 362 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 363 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 364 | CLANG_WARN_UNREACHABLE_CODE = YES; 365 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 366 | CODE_SIGN_IDENTITY = "iPhone Developer"; 367 | COPY_PHASE_STRIP = NO; 368 | DEBUG_INFORMATION_FORMAT = dwarf; 369 | ENABLE_STRICT_OBJC_MSGSEND = YES; 370 | ENABLE_TESTABILITY = YES; 371 | GCC_C_LANGUAGE_STANDARD = gnu11; 372 | GCC_DYNAMIC_NO_PIC = NO; 373 | GCC_NO_COMMON_BLOCKS = YES; 374 | GCC_OPTIMIZATION_LEVEL = 0; 375 | GCC_PREPROCESSOR_DEFINITIONS = ( 376 | "DEBUG=1", 377 | "$(inherited)", 378 | ); 379 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 380 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 381 | GCC_WARN_UNDECLARED_SELECTOR = YES; 382 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 383 | GCC_WARN_UNUSED_FUNCTION = YES; 384 | GCC_WARN_UNUSED_VARIABLE = YES; 385 | IPHONEOS_DEPLOYMENT_TARGET = 11.3; 386 | MTL_ENABLE_DEBUG_INFO = YES; 387 | ONLY_ACTIVE_ARCH = YES; 388 | SDKROOT = iphoneos; 389 | }; 390 | name = Debug; 391 | }; 392 | F13E871920A0232F00DD6556 /* Release */ = { 393 | isa = XCBuildConfiguration; 394 | buildSettings = { 395 | ALWAYS_SEARCH_USER_PATHS = NO; 396 | CLANG_ANALYZER_NONNULL = YES; 397 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 398 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 399 | CLANG_CXX_LIBRARY = "libc++"; 400 | CLANG_ENABLE_MODULES = YES; 401 | CLANG_ENABLE_OBJC_ARC = YES; 402 | CLANG_ENABLE_OBJC_WEAK = YES; 403 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 404 | CLANG_WARN_BOOL_CONVERSION = YES; 405 | CLANG_WARN_COMMA = YES; 406 | CLANG_WARN_CONSTANT_CONVERSION = YES; 407 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 408 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 409 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 410 | CLANG_WARN_EMPTY_BODY = YES; 411 | CLANG_WARN_ENUM_CONVERSION = YES; 412 | CLANG_WARN_INFINITE_RECURSION = YES; 413 | CLANG_WARN_INT_CONVERSION = YES; 414 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 415 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 416 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 417 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 418 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 419 | CLANG_WARN_STRICT_PROTOTYPES = YES; 420 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 421 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 422 | CLANG_WARN_UNREACHABLE_CODE = YES; 423 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 424 | CODE_SIGN_IDENTITY = "iPhone Developer"; 425 | COPY_PHASE_STRIP = NO; 426 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 427 | ENABLE_NS_ASSERTIONS = NO; 428 | ENABLE_STRICT_OBJC_MSGSEND = YES; 429 | GCC_C_LANGUAGE_STANDARD = gnu11; 430 | GCC_NO_COMMON_BLOCKS = YES; 431 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 432 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 433 | GCC_WARN_UNDECLARED_SELECTOR = YES; 434 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 435 | GCC_WARN_UNUSED_FUNCTION = YES; 436 | GCC_WARN_UNUSED_VARIABLE = YES; 437 | IPHONEOS_DEPLOYMENT_TARGET = 11.3; 438 | MTL_ENABLE_DEBUG_INFO = NO; 439 | SDKROOT = iphoneos; 440 | VALIDATE_PRODUCT = YES; 441 | }; 442 | name = Release; 443 | }; 444 | F13E871B20A0232F00DD6556 /* Debug */ = { 445 | isa = XCBuildConfiguration; 446 | buildSettings = { 447 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 448 | CODE_SIGN_STYLE = Automatic; 449 | INFOPLIST_FILE = CustomCodeInput/Info.plist; 450 | LD_RUNPATH_SEARCH_PATHS = ( 451 | "$(inherited)", 452 | "@executable_path/Frameworks", 453 | ); 454 | PRODUCT_BUNDLE_IDENTIFIER = com.main.CustomCodeInput; 455 | PRODUCT_NAME = "$(TARGET_NAME)"; 456 | TARGETED_DEVICE_FAMILY = "1,2"; 457 | }; 458 | name = Debug; 459 | }; 460 | F13E871C20A0232F00DD6556 /* Release */ = { 461 | isa = XCBuildConfiguration; 462 | buildSettings = { 463 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 464 | CODE_SIGN_STYLE = Automatic; 465 | INFOPLIST_FILE = CustomCodeInput/Info.plist; 466 | LD_RUNPATH_SEARCH_PATHS = ( 467 | "$(inherited)", 468 | "@executable_path/Frameworks", 469 | ); 470 | PRODUCT_BUNDLE_IDENTIFIER = com.main.CustomCodeInput; 471 | PRODUCT_NAME = "$(TARGET_NAME)"; 472 | TARGETED_DEVICE_FAMILY = "1,2"; 473 | }; 474 | name = Release; 475 | }; 476 | F13E871E20A0232F00DD6556 /* Debug */ = { 477 | isa = XCBuildConfiguration; 478 | buildSettings = { 479 | BUNDLE_LOADER = "$(TEST_HOST)"; 480 | CODE_SIGN_STYLE = Automatic; 481 | INFOPLIST_FILE = CustomCodeInputTests/Info.plist; 482 | LD_RUNPATH_SEARCH_PATHS = ( 483 | "$(inherited)", 484 | "@executable_path/Frameworks", 485 | "@loader_path/Frameworks", 486 | ); 487 | PRODUCT_BUNDLE_IDENTIFIER = com.main.CustomCodeInputTests; 488 | PRODUCT_NAME = "$(TARGET_NAME)"; 489 | TARGETED_DEVICE_FAMILY = "1,2"; 490 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/CustomCodeInput.app/CustomCodeInput"; 491 | }; 492 | name = Debug; 493 | }; 494 | F13E871F20A0232F00DD6556 /* Release */ = { 495 | isa = XCBuildConfiguration; 496 | buildSettings = { 497 | BUNDLE_LOADER = "$(TEST_HOST)"; 498 | CODE_SIGN_STYLE = Automatic; 499 | INFOPLIST_FILE = CustomCodeInputTests/Info.plist; 500 | LD_RUNPATH_SEARCH_PATHS = ( 501 | "$(inherited)", 502 | "@executable_path/Frameworks", 503 | "@loader_path/Frameworks", 504 | ); 505 | PRODUCT_BUNDLE_IDENTIFIER = com.main.CustomCodeInputTests; 506 | PRODUCT_NAME = "$(TARGET_NAME)"; 507 | TARGETED_DEVICE_FAMILY = "1,2"; 508 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/CustomCodeInput.app/CustomCodeInput"; 509 | }; 510 | name = Release; 511 | }; 512 | F13E872120A0232F00DD6556 /* Debug */ = { 513 | isa = XCBuildConfiguration; 514 | buildSettings = { 515 | CODE_SIGN_STYLE = Automatic; 516 | INFOPLIST_FILE = CustomCodeInputUITests/Info.plist; 517 | LD_RUNPATH_SEARCH_PATHS = ( 518 | "$(inherited)", 519 | "@executable_path/Frameworks", 520 | "@loader_path/Frameworks", 521 | ); 522 | PRODUCT_BUNDLE_IDENTIFIER = com.main.CustomCodeInputUITests; 523 | PRODUCT_NAME = "$(TARGET_NAME)"; 524 | TARGETED_DEVICE_FAMILY = "1,2"; 525 | TEST_TARGET_NAME = CustomCodeInput; 526 | }; 527 | name = Debug; 528 | }; 529 | F13E872220A0232F00DD6556 /* Release */ = { 530 | isa = XCBuildConfiguration; 531 | buildSettings = { 532 | CODE_SIGN_STYLE = Automatic; 533 | INFOPLIST_FILE = CustomCodeInputUITests/Info.plist; 534 | LD_RUNPATH_SEARCH_PATHS = ( 535 | "$(inherited)", 536 | "@executable_path/Frameworks", 537 | "@loader_path/Frameworks", 538 | ); 539 | PRODUCT_BUNDLE_IDENTIFIER = com.main.CustomCodeInputUITests; 540 | PRODUCT_NAME = "$(TARGET_NAME)"; 541 | TARGETED_DEVICE_FAMILY = "1,2"; 542 | TEST_TARGET_NAME = CustomCodeInput; 543 | }; 544 | name = Release; 545 | }; 546 | /* End XCBuildConfiguration section */ 547 | 548 | /* Begin XCConfigurationList section */ 549 | F13E86E920A0232D00DD6556 /* Build configuration list for PBXProject "CustomCodeInput" */ = { 550 | isa = XCConfigurationList; 551 | buildConfigurations = ( 552 | F13E871820A0232F00DD6556 /* Debug */, 553 | F13E871920A0232F00DD6556 /* Release */, 554 | ); 555 | defaultConfigurationIsVisible = 0; 556 | defaultConfigurationName = Release; 557 | }; 558 | F13E871A20A0232F00DD6556 /* Build configuration list for PBXNativeTarget "CustomCodeInput" */ = { 559 | isa = XCConfigurationList; 560 | buildConfigurations = ( 561 | F13E871B20A0232F00DD6556 /* Debug */, 562 | F13E871C20A0232F00DD6556 /* Release */, 563 | ); 564 | defaultConfigurationIsVisible = 0; 565 | defaultConfigurationName = Release; 566 | }; 567 | F13E871D20A0232F00DD6556 /* Build configuration list for PBXNativeTarget "CustomCodeInputTests" */ = { 568 | isa = XCConfigurationList; 569 | buildConfigurations = ( 570 | F13E871E20A0232F00DD6556 /* Debug */, 571 | F13E871F20A0232F00DD6556 /* Release */, 572 | ); 573 | defaultConfigurationIsVisible = 0; 574 | defaultConfigurationName = Release; 575 | }; 576 | F13E872020A0232F00DD6556 /* Build configuration list for PBXNativeTarget "CustomCodeInputUITests" */ = { 577 | isa = XCConfigurationList; 578 | buildConfigurations = ( 579 | F13E872120A0232F00DD6556 /* Debug */, 580 | F13E872220A0232F00DD6556 /* Release */, 581 | ); 582 | defaultConfigurationIsVisible = 0; 583 | defaultConfigurationName = Release; 584 | }; 585 | /* End XCConfigurationList section */ 586 | }; 587 | rootObject = F13E86E620A0232D00DD6556 /* Project object */; 588 | } 589 | --------------------------------------------------------------------------------