Code Monkey home page Code Monkey logo

emojikeybboard's Introduction

EmojiKeybBoard

原文链接:https://github.com/iiicp/KeyboardforChat

适配iPhone X系列,增加转换文字图片

原文链接:https://github.com/iiicp/KeyboardforChat

KeyboardForChat

仿微信聊天键盘。
优点:无污染,无任何第三方,使用简单。

#特性

  1. 支持语音、表情、more,并且可以关闭、打开。
  2. 单个主题表情采用collectionView,节约内存空间。整体实现是ScrollView+collectionView
  3. 聊天输入框支持placehold
  4. 支持在任意的控制器里面添加,但是要注意在初始化方法中传入的frame.
  5. 支持作为聊天键盘和点击评论按钮从屏幕外弹出键盘使用。
  6. 支持emoji表情、自定义表情。

控件使用效果

![](2016-04-08 18_58_24.gif)

控件使用步骤

代码

  1. 导入KeyBoard文件夹
  2. 资源文件是 emotion.plist 和 face.plist 图片在 Assets.xcassets
  3. 导入ChatKeyBoard.h即可使用,具体参考demo

添加数据源

/****************************************************************
*  关于初始化方法
*
*  1,如果只是一个带导航栏的页面,且导航栏透明。
或者根本就没有导航栏
*
*  使用  [ChatKeyBoard keyBoard]; 
[ChatKeyBoard keyBoardWithNavgationBarTranslucent:YES]
*       [ChatKeyBoard keyBoardWithParentViewBounds:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]
*
*
*  2,如果只是一个带导航栏的页面,导航栏不透明

* 使用  [ChatKeyBoard keyBoardWithNavgationBarTranslucent:NO]
[ChatKeyBoard keyBoardWithParentViewBounds:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height-64)]
*
*
*  3, 如果页面顶部还有一些标签栏,类似腾讯视频、今日头条、网易新闻之类的
*
* 请使用  [ChatKeyBoard keyBoardWithParentViewBounds:bounds]
传入子视图控制器的bounds
*
******************************************************************/

self.chatKeyBoard = [ChatKeyBoard keyBoard];
self.chatKeyBoard.delegate = self;
self.chatKeyBoard.dataSource = self;

self.chatKeyBoard.placeHolder = @"请输入消息,请输入消息,请输入消息,请输入消息,请输入消息,请输入消息,请输入消息,请输入消息";

/*
*  支持切换评论键盘
*  self.chatKeyBoard.keyBoardStyle = KeyBoardStyleComment;
*
*  则可以使用下面两个方法,开启评论和关闭评论键盘
- (void)keyboardUpforComment;
- (void)keyboardDownForComment;
*/

/*
*  支持外部操纵键盘  (这两个方法是在正常聊天界面,非评论)
- (void)keyboardUp;
- (void)keyboardDown;
*/

[self.view addSubview:self.chatKeyBoard];

实现数据源代理

- (NSArray<MoreItem *> *)chatKeyBoardMorePanelItems
{
MoreItem *item1 = [MoreItem moreItemWithPicName:@"sharemore_location" highLightPicName:nil itemName:@"位置"];
MoreItem *item2 = [MoreItem moreItemWithPicName:@"sharemore_pic" highLightPicName:nil itemName:@"图片"];
MoreItem *item3 = [MoreItem moreItemWithPicName:@"sharemore_video" highLightPicName:nil itemName:@"拍照"];
MoreItem *item4 = [MoreItem moreItemWithPicName:@"sharemore_location" highLightPicName:nil itemName:@"位置"];
MoreItem *item5 = [MoreItem moreItemWithPicName:@"sharemore_pic" highLightPicName:nil itemName:@"图片"];
MoreItem *item6 = [MoreItem moreItemWithPicName:@"sharemore_video" highLightPicName:nil itemName:@"拍照"];
MoreItem *item7 = [MoreItem moreItemWithPicName:@"sharemore_location" highLightPicName:nil itemName:@"位置"];
MoreItem *item8 = [MoreItem moreItemWithPicName:@"sharemore_pic" highLightPicName:nil itemName:@"图片"];
MoreItem *item9 = [MoreItem moreItemWithPicName:@"sharemore_video" highLightPicName:nil itemName:@"拍照"];
return @[item1, item2, item3, item4, item5, item6, item7, item8, item9];
}
- (NSArray<ChatToolBarItem *> *)chatKeyBoardToolbarItems
{
ChatToolBarItem *item1 = [ChatToolBarItem barItemWithKind:kBarItemFace normal:@"face" high:@"face_HL" select:@"keyboard"];

ChatToolBarItem *item2 = [ChatToolBarItem barItemWithKind:kBarItemVoice normal:@"voice" high:@"voice_HL" select:@"keyboard"];

ChatToolBarItem *item3 = [ChatToolBarItem barItemWithKind:kBarItemMore normal:@"more_ios" high:@"more_ios_HL" select:nil];

ChatToolBarItem *item4 = [ChatToolBarItem barItemWithKind:kBarItemSwitchBar normal:@"switchDown" high:nil select:nil];

return @[item1, item2, item3, item4];
}

- (NSArray<FaceThemeModel *> *)chatKeyBoardFacePanelSubjectItems
{
return [FaceSourceManager loadFaceSource];
}

##控件里面的一些View可以自己定制,里面只是稍微演示 PanelBottomView OfficialAccountToolbar

##控件可以根据业务需要,更换业务模型 MoreItem
ChatToolBarItem
FaceThemeModel
FaceSourceManager

##感谢
MessageDisplayKit JSQMessagesViewController

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.