今天剛好520,單身的iOS狗扎心不O(∩_∩)O哈哈~ 好了,不扯犢子,進入話題
公司最近正在開發(fā)直播項目,為了省錢接了一個聽都沒聽過的直播,emmmm,不想多少,接入了各種問題,唯一頭疼的就是表情鍵盤,剛開始網上摸爬滾打,不是沒設配iPhoneX以上的設備,就是動畫寫的不盡人意,開發(fā)接入尾聲時間,忽然想起之前接過一個私活,騰訊云直播里面有表情鍵盤,果斷pod一下,把鍵盤單拎出來,各種改各種搓,終于在快下班時候成功了,哈哈,在此分享給哪些爬坑的小伙伴們,同時感謝騰訊云前輩們造的輪子
8`ZEOT}%V7WMQWFLJRH5QHM.jpg
8`ZEOT}%V7WMQWFLJRH5QHM.jpg
-
效果圖
未命名.gif
簡單修了一些業(yè)務上的bug
- 修復了表情鍵盤只能刪除表情的問題
- 刪除了一些騰訊云里面無用的文件以及代碼
- 支持自定義表情
站在前輩們的肩膀上開發(fā):
- 激動人人心的時候到來了,上面都是扯犢子,下面咱們看看怎么用吧 上硬菜O(∩_∩)O哈哈~
_inputController = [[LLInputController alloc] init];
_inputController.view.frame = CGRectMake(0, self.view.frame.size.height - TTextView_Height - Bottom_SafeHeight, self.view.frame.size.width, TTextView_Height + Bottom_SafeHeight);
_inputController.view.autoresizingMask = UIViewAutoresizingFlexibleTopMargin;
_inputController.delegate = self;
[self addChildViewController:_inputController];
[self.view addSubview:_inputController.view];
-
是不是驚了 就這么簡單 1.png
- 當然還要遵循代理 實現(xiàn)代理方法
- (void)inputController:(LLInputController *)inputController didChangeHeight:(CGFloat)height
{
__weak typeof(self) ws = self;
[UIView animateWithDuration:0.3 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{
CGRect msgFrame = CGRectMake(0, 0, CGRectGetWidth(self.view.frame), CGRectGetHeight(self.view.frame) - CGRectGetHeight(self.inputController.view.frame));
msgFrame.size.height = ws.view.frame.size.height - height;
CGRect inputFrame = ws.inputController.view.frame;
inputFrame.origin.y = msgFrame.origin.y + msgFrame.size.height;
inputFrame.size.height = height;
ws.inputController.view.frame = inputFrame;
} completion:nil];
}
- (void)inputController:(LLInputController *)inputController didSendMessage:(id)msg {
if ([msg isKindOfClass:[NSString class]]) {
NSLog(@"發(fā)送的文本消息 內容====%@",msg);
return;
}
if ([msg isKindOfClass:[AVURLAsset class]]) {
AVURLAsset *audioAsset = msg;
int duration = (int)CMTimeGetSeconds(audioAsset.duration);
int length = (int)[[[NSFileManager defaultManager] attributesOfItemAtPath:[audioAsset.URL path] error:nil] fileSize];
NSLog(@"發(fā)送的語音消息 語音長度====%d 長度== %d",duration,length);
return;
}
}
- (void)inputController:(LLInputController *)inputController didSelectMoreCell:(LLInputMoreCell *)cell {
if ([cell.data.title isEqualToString:@"相冊"]) {
NSLog(@"點擊了相冊");
return;
}
if ([cell.data.title isEqualToString:@"拍照"]) {
NSLog(@"點擊了拍照");
return;
}
}
191A69CF-1854-4A26-9B82-2869F0B4BBBB.png
- 結束啦
- 最后附上demo
https://github.com/lanyuzx/VXKeyborad/tree/master