iOS自定义数字键盘

作者: _Comma | 来源:发表于2017-06-23 11:19 被阅读166次

    因为项目需求,简单的弄了个自定义数字键盘

    需要的自取,大神勿喷

    Untitled.gif

    使用也很简单

    #import "JKNumberTextField.h"
    
    //代理<JKNumberTextFieldDelegate>
    
    JKNumberTextField *textField = [[JKNumberTextField alloc] init];
        textField.JKDelegate = self;
        /** 创建用init,代理注意不要写成delegete了
         *  继承于YUTextField,设置属性就好,暂不支持xib和sb
         */
        textField.frame = CGRectMake(50, 200, 200, 30);
        textField.borderStyle = UITextBorderStyleRoundedRect;
        [self.view addSubview:textField];
    
    
    //实现代理方法即可
    
    /**点击收键盘时调用*/
    - (void)textFieldDidComplete:(JKNumberTextField *)textField andText:(NSString *)text {
        [textField resignFirstResponder];
    }
    
    /**值变化时调用*/
    - (void)textFieldDidChangeAnyValue:(JKNumberTextField *)textField andText:(NSString *)text {
        
    }
    
    

    这里是GitHub地址

    相关文章

      网友评论

      本文标题:iOS自定义数字键盘

      本文链接:https://www.haomeiwen.com/subject/upfccxtx.html