
仿新浪微博表情键盘

cd
到项目目录,输入以下命令,建立 Podfile
$ pod init
platform :ios, '8.0'
use_frameworks!
target 'ProjectName' do
pod 'HMEmoticon'
end
# 安装 Pod,第一次使用
$ pod install
# 升级 Pod,后续使用
$ pod update
@import HMEmoticon;
UITextView
的 Class
修改为 HMEmoticonTextView
@property (weak, nonatomic) IBOutlet HMEmoticonTextView *textView;
Default
// 1. 设置用户标示 - 用于保存最近使用表情
[HMEmoticonManager sharedManager].userIdentifier = @"刀哥";
// 1> 使用表情视图
_textView.useEmoticonInputView = YES;
// 2> 设置占位文本
_textView.placeholder = @"分享新鲜事...";
// 3> 设置最大文本长度
_textView.maxInputLength = 140;
_textView.useEmoticonInputView = !_textView.isUseEmoticonInputView;
符号字符串
转换成 带表情图片的属性字符串
NSString *text = @"[爱你]啊[笑哈哈]";
NSAttributedString *attributeText = [[HMEmoticonManager sharedManager]
emoticonStringWithString:text
font:_textView.font
textColor:_textView.textColor];
符号字符串
_textView.emoticonText