IM开发

IOS1:1完美仿微信聊天表情键盘,聊天+朋友圈键盘。ios微信

2021-08-31  本文已影响0人  大鼓书

Github链接

简介:

基础功能:

进阶功能:

效果gif图(Gif图有点卡,实际运行一点都不卡):


安装

先在终端里搜索 pod search QKeyboardEmotionView

如果搜索不到2.0版本,需要更新你电脑的pod仓库,以下是更新步骤:

OC 调用方式:

- (void)viewDidLoad {
    [super viewDidLoad];
    
    // 初始化输入工具条,frame可以先这样临时设置,下面的addBottomInputBarView方法会重置输入条frame
    // 如果你想要自定义输入条View,请参考TextFieldViewController代码
    _inputView = [[QInputBarView alloc] initWithFrame:CGRectMake(0,0,self.view.frame.size.width,UIInputBarViewMinHeight)];
    _inputView.dataSource = self;
    _inputView.delegate = self;
    
    //keyboard管理类,用来管理键盘,各大面板的切换
    _keyboardManager = [[QKeyboardManager alloc] initWithViewController:self];
    _keyboardManager.dataSource = self;
    //因为addBottomInputBarView方法会立刻触发delegate,所以这里需要先设置delegate
    _keyboardManager.delegate = self;
    //将输入条View添加到ViewController;YES表示输入条平时不显示(比如朋友圈);NO表示平时也显示(比如聊天)
    [_keyboardManager addBottomInputBarView:_inputView belowViewController:NO];
    
    //把输入框(如果有的话)绑定给管理类
    [_keyboardManager bindTextView:_inputView.inputTextView];
}

Swift 调用方式:

override func viewDidLoad() {
    super.viewDidLoad()
    
    // 初始化输入工具条,frame可以先这样临时设置,下面的addBottomInputBarView方法会重置输入条frame
    // 如果你想要自定义输入条View,请参考TextFieldViewController代码
    bottomInputView = QInputBarView(frame: CGRect.init(x: 0, y: 0, width: view.frame.size.width, height: CGFloat(UIInputBarViewMinHeight)))
    bottomInputView.delegate = self;
    
    //keyboard管理类,用来管理键盘,各大面板的切换
    keyboardManager = QKeyboardManager(viewController: self);
    keyboardManager.dataSource = self;
    //因为addBottomInputBarView方法会立刻触发delegate,所以这里需要先设置delegate,再addBottomInputBarView
    keyboardManager.delegate = self;
    //将输入条View添加到ViewController;YES表示输入条平时不显示(比如朋友圈);NO表示平时也显示(比如聊天)
    keyboardManager.addBottomInputBarView(bottomInputView, belowViewController: belowViewController())
    
    //把输入框(如果有的话)绑定给管理类
    keyboardManager.bindTextView(bottomInputView.inputTextView)
}

参数配置

@property (nonatomic, strong) UIColor *inputBarBackgroundColor;//输入条颜色,默认仿微信的灰色
@property (nonatomic, strong) UIColor *inputBarBoardColor;//输入条上方的的那一条细横线的颜色
@property (nonatomic, strong) UIColor *textColor;//输入栏textview的颜色
@property (nonatomic, strong) UIColor *textViewBackgroundColor;//输入栏textview的背景颜色,默认白色
@property (nonatomic, strong) UIColor *recordButtonTitleColor;//按住说话按钮的字体颜色
@property (nonatomic, assign) BOOL voiceButtonHidden; //是否隐藏发送语音 default is NO
@property (nonatomic, assign) BOOL extendButtonHidden; //是否隐藏发送多媒体 default is NO
@property (nonatomic, assign) BOOL emotionButtonHidden; //是否隐藏发送表情 default is NO

/// 点击键盘右下角的按钮是否是发送,NO表示普通回车换行,YES表示回调Delegate的Send方法
@property (nonatomic, assign) BOOL keyboardSendEnabled; // default is YES

导入方式

pod 'QKeyboardEmotionView'

以后还会有更多好库开源,求个Star

Github链接

上一篇 下一篇

猜你喜欢

热点阅读