UITextView(FWKeyboard)

@interface UITextView (FWKeyboard)
extension UITextView: SkeletonViewDataSource

多行输入框键盘管理分类

Keyboard

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

    Declaration

    Objective-C

    @property (nonatomic) BOOL fw_keyboardManager;
  • 设置输入框和键盘的空白高度,默认10.0

    Declaration

    Objective-C

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

    Declaration

    Objective-C

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

    Declaration

    Objective-C

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

    Declaration

    Objective-C

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

    Declaration

    Objective-C

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

Return

  • 点击键盘完成按钮是否关闭键盘,默认NO,二选一。此方法会修改delegate,可使用fwDelegate访问原始delegate

    Declaration

    Objective-C

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

    Declaration

    Objective-C

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

    Declaration

    Objective-C

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

    Declaration

    Objective-C

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

Toolbar

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

    Declaration

    Objective-C

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

    Declaration

    Objective-C

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

    Declaration

    Objective-C

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

    Declaration

    Objective-C

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

    Declaration

    Objective-C

    @property (nonatomic, copy, nullable) UIResponder *_Nullable (^) (UITextView *_Nonnull __strong) fw_previousResponder;
  • 设置Toolbar点击下一个按钮时聚焦的输入框句柄,默认nil

    Declaration

    Objective-C

    @property (nonatomic, copy, nullable) UIResponder *_Nullable (^) (UITextView *_Nonnull __strong) fw_nextResponder;
  • 设置Toolbar点击前一个按钮时聚焦的输入框tag,默认0不生效

    Declaration

    Objective-C

    @property (nonatomic) NSInteger fw_previousResponderTag;
  • 设置Toolbar点击下一个按钮时聚焦的输入框tag,默认0不生效

    Declaration

    Objective-C

    @property (nonatomic) NSInteger fw_nextResponderTag;
  • 自动跳转前一个输入框,优先使用previousResponder,其次根据responderTag查找

    Declaration

    Objective-C

    - (void)fw_goPrevious;
  • 自动跳转后一个输入框,优先使用nextResponder,其次根据responderTag查找

    Declaration

    Objective-C

    - (void)fw_goNext;
  • 获取键盘弹出时的高度,对应Key为UIKeyboardFrameEndUserInfoKey

    Declaration

    Objective-C

    - (CGFloat)fw_keyboardHeight:(nonnull NSNotification *)notification;
  • 执行键盘跟随动画,支持AutoLayout,可通过keyboardHeight:获取键盘高度

    Declaration

    Objective-C

    - (void)fw_keyboardAnimate:(nonnull NSNotification *)notification
                    animations:(nonnull void (^)(void))animations
                    completion:(void (^_Nullable __strong)(BOOL))completion;
  • 添加Toolbar,指定标题和完成句柄,使用默认按钮

    Declaration

    Objective-C

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

    Parameters

    title

    标题,不能点击

    doneBlock

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

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

    Declaration

    Objective-C

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

    Parameters

    titleItem

    居中标题按钮

    previousItem

    左侧前一个按钮

    nextItem

    左侧下一个按钮

    doneItem

    右侧完成按钮

UITextView+FWPlaceholder

  • 占位文本,默认nil

    Declaration

    Objective-C

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

    Declaration

    Objective-C

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

    Declaration

    Objective-C

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

    Declaration

    Objective-C

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

    Declaration

    Objective-C

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

    Declaration

    Objective-C

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

    Declaration

    Objective-C

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

    Declaration

    Objective-C

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

    Declaration

    Objective-C

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

    Declaration

    Objective-C

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

UITextView+FWUIKit

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

    Declaration

    Objective-C

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

    Declaration

    Objective-C

    @property (nonatomic) NSInteger fw_maxUnicodeLength;
  • 自定义文字改变处理句柄,自动trimString,默认nil

    Declaration

    Objective-C

    @property (nonatomic, copy, nullable) void (^) (NSString *_Nonnull __strong) fw_textChangedBlock;
  • 文本长度发生改变,自动检测字数限制,用于代码设置text等场景

    Declaration

    Objective-C

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

    Declaration

    Objective-C

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

    Declaration

    Objective-C

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

    Declaration

    Objective-C

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

Menu

  • Undocumented

    Declaration

    Objective-C

    @property (nonatomic) BOOL fw_menuDisabled

Select

  • Undocumented

    Declaration

    Objective-C

    @property (nonatomic, strong, null_resettable) UIColor *fw_cursorColor
  • Undocumented

    Declaration

    Objective-C

    @property (nonatomic) CGRect fw_cursorRect
  • Undocumented

    Declaration

    Objective-C

    @property (nonatomic) NSRange fw_selectedRange
  • Undocumented

    Declaration

    Objective-C

    - (void)fw_selectAllRange NS_REFINED_FOR_SWIFT;
  • Undocumented

    Declaration

    Objective-C

    - (void)fw_moveCursor:(NSInteger)offset NS_REFINED_FOR_SWIFT;

Size

  • Undocumented

    Declaration

    Objective-C

    @property (nonatomic, readonly) CGSize fw_textSize
  • Undocumented

    Declaration

    Objective-C

    @property (nonatomic, readonly) CGSize fw_attributedTextSize

UIKit+SkeletonView