iMessage Apps - 以编程方式从.apng创建动画贴纸 [英] iMessage Apps - Programatically create animated sticker from .apng

查看:259
本文介绍了iMessage Apps - 以编程方式从.apng创建动画贴纸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您有没有人尝试以编程方式使用动画apng文件以编程方式创建自定义贴纸?

Hi has anyone tried yet to programatically create a custom sticker programmatically with an animated apng file?

我没有成功,但可以声明以下内容:

I've had no success but can state the following:


  1. .apng文件的正确尺寸和文件大小(300px * 300px)和< 500kb。

  1. .apng file of correct dimensions and file size (300px * 300px) and < 500kb.

可以将其添加为.png并显示第一帧(不是动画)

Can add this as a .png and it shows the first frame (not animated)

将文件名更改为.apng会导致在将贴纸插入MS Message时引发错误。

Changing file name to .apng causes an error to be raised upon inserting sticker to MS Message.

已经采取了将apng加载到项目文件夹(而不是在Assets.xcassets中)的方法,因为初始化标签需要NSURL,如果没有可用的NSURL apng是作为iOS贴纸创建的。

Have taken the approach of loading the apng into the project folder (not in Assets.xcassets) as the initialize sticker requires an NSURL which is not made availabe if apng is created as an iOS sticker.

管理用户在.GIF中使用相同的序列。这正确插入贴纸。

Managed to user the same sequence in .GIF. this inserted correctly as a sticker.

以下代码:

MSConversation *currentConversation = [self activeConversation];

NSURL *urlForSticker2 = [[NSBundle mainBundle] URLForResource:@"elephant_apng" withExtension:@"apng"];
MSSticker *challengeSticker2 = [[MSSticker alloc] initWithContentsOfFileURL:urlForSticker2 localizedDescription:@"My Sticker Localised" error:&myError];

[currentConversation insertSticker:challengeSticker2 completionHandler:^(NSError * error) 
{

//HERE we get: error    NSError *   domain: @"com.apple.messages.stickers-error" - code: 8  0x0000600000058240


 }];

所以是 - 希望能够克服上面显示的错误。

So yes - keen to be able to overcome the error shown above.

推荐答案

也许你在添加资源时忘了点击这里?

Maybe you forget click here when you add the resource?

当您插入MSSticker对象时,您的apng文件的扩展名应该只是png

and your apng file's extension should be just "png" when you insert a MSSticker object.

这篇关于iMessage Apps - 以编程方式从.apng创建动画贴纸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆