A versatile, highly customizable input view for iOS. It supports various text input customizations, including keyboard settings, caret styles, box alignment, and input length constraints. The view conforms to the UITextInput
protocol and offers a flexible, user-friendly text input experience suitable for a wide range of applications.
PopUp | DropDown |
---|---|
|
|
-
UITextInput Compliance
Supports various text input customizations such as autocapitalization, autocorrection, spell checking, and more. -
Caret Customization
Control the appearance and behavior of the caret, including width, height, blink duration, and opacity. -
Box Style Customization
Customize the appearance and alignment of input boxes, including space between boxes, select transition duration, and auto-fill options. -
Menu Actions
Support for copy, paste, cut, and delete actions within the input view. -
Input Handling
Manage the input length, current input index, and handle custom input events. -
First Responder Control
Toggle the first responder status programmatically.
inputLength
- 输入的长度。
autocapitalizationType
- 控制文本是否应自动大写。autocorrectionType
- 控制文本是否应自动纠错。spellCheckingType
- 控制文本是否应进行拼写检查。smartQuotesType
- 控制是否应使用智能引号。smartDashesType
- 控制是否应使用智能破折号。smartInsertDeleteType
- 控制是否应使用智能插入/删除。keyboardType
- 要显示的键盘类型。keyboardAppearance
- 键盘的显示样式。returnKeyType
- 键盘的回车键类型。enablesReturnKeyAutomatically
- 控制是否自动启用回车键。textContentType
- 文本输入表示的内容类型。passwordRules
- 文本输入的密码规则。
copyable
- 控制文本是否可复制。pasteable
- 控制文本是否可粘贴。cutable
- 控制文本是否可剪切。deleteable
- 控制文本是否可删除。setMenuable:
- 设置文本菜单是否启用。
showCaret
- 控制是否显示光标。caretWidth
- 光标的宽度。caretHeight
- 光标的高度。caretMaxOpacity
- 光标的最大不透明度。caretMinOpacity
- 光标的最小不透明度。blinkDuration
- 光标闪烁动画的持续时间。
boxSpace
- 间距之间的空间。selectTransitionDuration
- 选择过渡动画的持续时间。alignment
- 方框的对齐方式。autoDismissKeyBoardWhenFinishInput
- 控制是否在输入完成后自动关闭键盘。autoFillBoxContainer
- 控制是否自动填充方框容器。isRTL
- 控制文本输入是否处于从右到左模式。placeHolder
- 输入的占位文本。inputText
- 当前输入文本。currentInputIndex
- 当前输入索引(只读)。inputMaxLength
- 输入的最大长度(只读)。onClickInputViewBlock
- 当点击输入视图时调用的一个块。
initWithInputLength:
- 使用指定长度初始化输入视图。boxInputWithLength:
- 创建一个新的指定长度的输入视图。
#import "BRCBoxInputView.h"
// Create an input view with a specified length
BRCBoxInputView *inputView = [[BRCBoxInputView alloc] initWithInputLength:6];
// Customize appearance
inputView.autocapitalizationType = UITextAutocapitalizationTypeWords;
inputView.autocorrectionType = UITextAutocorrectionTypeNo;
inputView.keyboardType = UIKeyboardTypeNumberPad;
inputView.placeHolder = @"Enter Code";
// Set caret properties
inputView.showCaret = YES;
inputView.caretWidth = 2.0;
inputView.caretMaxOpacity = 1.0;
// Set box style properties
inputView.boxSpace = 8.0;
inputView.selectTransitionDuration = 0.25;
inputView.alignment = BRCBoxAlignmentCenter;
// Show the input view
[inputView toggleFirstResponder];
BRCBoxInputView 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中
pod 'BRCBoxInputView', '~> 1.0'
iOS 13.0+ Xcode 12+
- iOS 13.0
- Xcode 12+
zhixiongsun, [email protected]
BRCBoxInputView 在 MIT 许可下可用。有关更多信息,请参阅 LICENSE 文件。