FWTextFieldWrapper

@interface FWTextFieldWrapper : FWControlWrapper

Undocumented

Keyboard

  • 是否启用键盘管理(自动滚动),默认NO

    Declaration

    Objective-C

    @property (nonatomic) BOOL keyboardManager;
  • 设置输入框和键盘的空白间距,默认10.0

    Declaration

    Objective-C

    @property (nonatomic) CGFloat keyboardDistance;
  • 设置输入框和键盘的回弹触发最小距离,默认0始终回弹

    Declaration

    Objective-C

    @property (nonatomic) CGFloat reboundDistance;
  • 是否启用键盘后台关闭处理,退后台时收起键盘,回到前台时恢复键盘,解决系统退后台输入框跳动问题,默认NO

    Declaration

    Objective-C

    @property (nonatomic) BOOL keyboardResign;
  • 是否启用点击背景关闭键盘(会继续触发其它点击事件),默认NO

    Declaration

    Objective-C

    @property (nonatomic) BOOL touchResign;
  • 指定用于键盘管理滚动的scrollView,默认为nil,通过修改VC.view.frame实现

    Declaration

    Objective-C

    @property (nonatomic, weak, nullable) UIScrollView *keyboardScrollView;

Return

  • 点击键盘完成按钮是否关闭键盘,默认NO,二选一

    Declaration

    Objective-C

    @property (nonatomic) BOOL returnResign;
  • 设置点击键盘完成按钮自动切换的下一个输入框,二选一

    Declaration

    Objective-C

    @property (nonatomic, weak, nullable) UIResponder *returnResponder;
  • 设置点击键盘完成按钮的事件句柄

    Declaration

    Objective-C

    @property (nonatomic, copy, nullable) void (^)(UITextField *_Nonnull) returnBlock;

Toolbar

  • 获取关联的键盘Toolbar对象,可自定义样式

    Declaration

    Objective-C

    @property (nonatomic, strong) UIToolbar *_Nonnull keyboardToolbar;
  • 自定义键盘Toolbar上一个按钮,支持图片|字符串等(详见FWBlock),默认朝上的箭头

    Declaration

    Objective-C

    @property (nonatomic, strong) id _Nonnull toolbarPreviousButton;
  • 自定义键盘Toolbar下一个按钮,支持图片|字符串等(详见FWBlock),默认朝下的箭头

    Declaration

    Objective-C

    @property (nonatomic, strong) id _Nonnull toolbarNextButton;
  • 自定义键盘Toolbar完成按钮,支持图片|字符串等(详见FWBlock),默认Done

    Declaration

    Objective-C

    @property (nonatomic, strong) id _Nonnull toolbarDoneButton;
  • 设置Toolbar点击前一个按钮时聚焦的输入框,默认nil

    Declaration

    Objective-C

    @property (nonatomic, weak, nullable) UIResponder *previousResponder;
  • 设置Toolbar点击下一个按钮时聚焦的输入框,默认nil

    Declaration

    Objective-C

    @property (nonatomic, weak, nullable) UIResponder *nextResponder;
  • 添加Toolbar,指定标题和完成句柄,使用默认按钮

    Declaration

    Objective-C

    - (void)addToolbarWithTitle:(nullable id)title
                      doneBlock:(nullable void (^)(id _Nonnull))doneBlock;

    Parameters

    title

    标题,不能点击

    doneBlock

    右侧完成按钮句柄,默认收起键盘

  • 添加Toolbar,指定居中标题、左侧上一个、下一个按钮和右边按钮

    Declaration

    Objective-C

    - (void)addToolbarWithTitleItem:(nullable UIBarButtonItem *)titleItem
                       previousItem:(nullable UIBarButtonItem *)previousItem
                           nextItem:(nullable UIBarButtonItem *)nextItem
                           doneItem:(nullable UIBarButtonItem *)doneItem;

    Parameters

    titleItem

    居中标题按钮

    previousItem

    左侧前一个按钮

    nextItem

    左侧下一个按钮

    doneItem

    右侧完成按钮

FWUIKit

  • 最大字数限制,0为无限制,二选一

    Declaration

    Objective-C

    @property (nonatomic) NSInteger maxLength;
  • 最大Unicode字数限制(中文为1,英文为0.5),0为无限制,二选一

    Declaration

    Objective-C

    @property (nonatomic) NSInteger maxUnicodeLength;
  • 文本长度发生改变,自动检测字数限制,用于代码设置text等场景

    Declaration

    Objective-C

    - (void)textLengthChanged;
  • 获取满足最大字数限制的过滤后的文本,无需再调用textLengthChanged

    Declaration

    Objective-C

    - (nonnull NSString *)filterText:(nonnull NSString *)text;
  • 设置自动完成时间间隔,默认1秒,和fwAutoCompleteBlock配套使用

    Declaration

    Objective-C

    @property (nonatomic) NSTimeInterval autoCompleteInterval;
  • 设置自动完成处理句柄,默认nil,注意输入框内容为空时会立即触发

    Declaration

    Objective-C

    @property (nonatomic, copy, nullable) void (^)(NSString *_Nonnull) autoCompleteBlock;