zoukankan      html  css  js  c++  java
  • 键盘工具栏的快速集成--IQKeyboardManager

    IQKeyboardManager,是一个键盘工具栏的库:

    默认支持UITextField、UITextView、UIWebView、UIScrollView、UITableView、UICollectionView

    左右两个切换按钮用来切换不同的文本框 会根据文本框的键盘类型对弹出键盘的样式做出调整  排列依据是看addSubView的先后顺序

    右边的done是用来收起键盘的  另外也可以设置点击空白区域收起键盘的属性

    中间的文字默认是文本框的占位文字

    因为这个库是单例模式的 也就是说无论在哪设置了一个属性 那么这个属性对全局都是生效的  所以一般我习惯把这个方法写在- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {}方法里面 

    另外  只要导入这个库  即使不做任何操作的话  默认也是会添加工具条的  

    使用:

    首先要导入收文件:

    #import "IQKeyboardManager.h"

    常用方法:

        IQKeyboardManager *manager = [IQKeyboardManager sharedManager];
        //控制整个功能是否启用。
        manager.enable = YES;
        //控制点击背景是否收起键盘
        manager.shouldResignOnTouchOutside = YES;
        //控制键盘上的工具条文字颜色是否用户自定义。  注意这个颜色是指textfile的tintcolor
        manager.shouldToolbarUsesTextFieldTintColor = YES;
        //中间位置是否显示占位文字
        manager.shouldShowTextFieldPlaceholder = YES;
        //设置占位文字的字体
        manager.placeholderFont = [UIFont boldSystemFontOfSize:17];
        //控制是否显示键盘上的工具条。
        manager.enableAutoToolbar = YES;
        //某个类中禁止使用工具条
        [[IQKeyboardManager sharedManager]disableToolbarInViewControllerClass:[UIViewController class]];

    效果图:

    地址:gitHub   Demo(提取码:50d4)   参考资料

    另外:这个库还自定义了带有展位文字的textView:

  • 相关阅读:
    toj 2819 Travel
    toj 2807 Number Sort
    zoj 2818 Prairie dogs IV
    zoj 1276 Optimal Array Multiplication Sequence
    toj 2802 Tom's Game
    toj 2798 Farey Sequence
    toj 2815 Searching Problem
    toj 2806 Replace Words
    toj 2794 Bus
    css截取字符
  • 原文地址:https://www.cnblogs.com/gaoxiaoniu/p/5333187.html
Copyright © 2011-2022 走看看