MMNumberKeyboard
一个简单的键盘,可用于数字,可选地包括小数点。
安装
来自CocoaPods
CocoaPods 是一个Objective-C的依赖管理器,它自动化并简化了将第三方库如MMNumberKeyboard
用于项目中。首先,将以下行添加到您的 Podfile
pod 'MMNumberKeyboard'
其次,将MMNumberKeyboard
安装到您的项目中
pod install
来自Carthage
Carthage 是一个Objective-C和Swift的依赖管理器。将以下行添加到您的 Cartfile
github "matmartinez/MMNumberKeyboard"
运行carthage update
。
请遵循Carthage的README文件中的最新安装说明。
用法
这里有一个可供使用的Xcode项目示例。只需构建并运行即可。
基本上,您可以实例化自己的键盘视图,将其用作UITextField
、UITextView
或任何支持文本编辑的视图的.inputView
。
// Create and configure the keyboard.
MMNumberKeyboard *keyboard = [[MMNumberKeyboard alloc] initWithFrame:CGRectZero];
keyboard.allowsDecimalPoint = YES;
keyboard.delegate = self;
// Configure an example UITextField.
UITextField *textField = [[UITextField alloc] initWithFrame:CGRectZero];
textField.inputView = keyboard;
您可以采用MMNumberKeyboardDelegate
协议来处理回车键或者是否插入文本。
开发
欢迎提交pull request。
鸣谢
感谢Pedro Burón对该README
文件的支持和鼓励。