可以支持发送的类型
这两种类型可以通过独立的应用和扩展创建。
满足的条件类型
支持允许使用@3x的图片 300px x 300px 到 618px x 618px 系统会自动生成@2x,@1x的图片
消息支持三种贴纸大小
系统要求
创建Motion的工程
下载模板工程
点击右下角打开 Size Frame Dimensions 小图 300x300 中图 408x408 大图 618x618
MSMessageAppViewController
MSStickerBrowserViewController
MSConversation
MSMessage
MSSession
@property(nonatomic, strong, readonly) MSConversation *activeConversation;
获取当前聊天的对象
[self.activeConversation insertText:@"Text Message" completionHandler:nil];
此方法异步执行
必须设置URL属性和Layout属性
@property (nonatomic, copy, nullable) NSURL *URL;
使用NSURLComponents
创建生成URL
属性
@property(nonatomic, copy) MSMessageLayout *layout;
使用MSMessageTemplateLayout
创建生成layout
属性
下面是这个layout的界面模板
怎么使用模板?
MSMessageTemplatelayout
的对象MSMessageTemplateLayout
的对象赋值给MSMessage
的layout
的属性MSMessageTemplateLayout
类1 发送简单的图片
MSMessageTemplateLayout *layout = [[MSMessageTemplateLayout alloc]init];
UIImage *image = [UIImage imageNamed:@"gb_simple_icon"];
layout.image = image;
2 发送文本和图片
在上面的代码上面添加
layout.imageTitle = @"Image Title";
3 发送文本图片 图片副标题
layout.imageSubtitle = @"Image SubTitle"
这样我们根据MSMessageTemplateLayout
类里面的属性控制模板的内容现在,大家可以自行设置查看样式
图片一定要满足下面
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"eat" ofType:@"gif"]];
MSSticker *sticker = [[MSSticker alloc] initWithContentsOfFileURL:url localizedDescription:@"Localized" error:nil];
[self.activeConversation insertSticker:sticker completionHandler:nil];
视频也要保存在工程里面
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"video" ofType:@"mov"]];
[self.activeConversation insertAttachment:url withAlternateFilename:nil completionHandler:nil];
MSMessagesAppPresentationStyleCompact
设置界面大小和键盘大小一致
MSMessagesAppPresentationStyleExpanded
设置界面的大小和iMessage的界面大小