FWTextViewWrapper

@interface FWTextViewWrapper : FWScrollViewWrapper

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,二选一。此方法会修改delegate,可使用fwDelegate访问原始delegate

    Declaration

    Objective-C

    @property (nonatomic) BOOL returnResign;
  • 设置点击键盘完成按钮自动切换的下一个输入框,二选一。此方法会修改delegate,可使用fwDelegate访问原始delegate

    Declaration

    Objective-C

    @property (nonatomic, weak, nullable) UIResponder *returnResponder;
  • 设置点击键盘完成按钮的事件句柄。此方法会修改delegate,可使用fwDelegate访问原始delegate

    Declaration

    Objective-C

    @property (nonatomic, copy, nullable) void (^)(UITextView *_Nonnull) returnBlock;
  • 调用上面三个方法后会修改delegate,此方法始终访问外部delegate

    Declaration

    Objective-C

    @property (nonatomic, weak, nullable) id<UITextViewDelegate> delegate;

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

    右侧完成按钮

FWPlaceholder

  • 占位文本,默认nil

    Declaration

    Objective-C

    @property (nonatomic, strong, nullable) NSString *placeholder;
  • 占位颜色,默认系统颜色

    Declaration

    Objective-C

    @property (nonatomic, strong, nullable) UIColor *placeholderColor;
  • 带属性占位文本,默认nil

    Declaration

    Objective-C

    @property (nonatomic, strong, nullable) NSAttributedString *attributedPlaceholder;
  • 自定义占位文本内间距,默认zero与内容一致

    Declaration

    Objective-C

    @property (nonatomic) UIEdgeInsets placeholderInset;
  • 自定义垂直分布方式,会自动修改contentInset,默认Top与系统一致

    Declaration

    Objective-C

    @property (nonatomic) UIControlContentVerticalAlignment verticalAlignment;
  • 是否启用自动高度功能,随文字改变高度

    Declaration

    Objective-C

    @property (nonatomic) BOOL autoHeightEnabled;
  • 最大高度,默认CGFLOAT_MAX,启用自动高度后生效

    Declaration

    Objective-C

    @property (nonatomic) CGFloat maxHeight;
  • 最小高度,默认0,启用自动高度后生效

    Declaration

    Objective-C

    @property (nonatomic) CGFloat minHeight;
  • 高度改变回调句柄,默认nil,启用自动高度后生效

    Declaration

    Objective-C

    @property (nonatomic, copy, nullable) void (^)(CGFloat) heightDidChange;
  • 快捷启用自动高度,并设置最大高度和回调句柄

    Declaration

    Objective-C

    - (void)autoHeightWithMaxHeight:(CGFloat)maxHeight
                          didChange:(nullable void (^)(CGFloat))didChange;

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;