iMessage Apps - Programatically create animated sticker from .apng

拜拜、爱过 提交于 2019-12-21 09:29:30

问题


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 file of correct dimensions and file size (300px * 300px) and < 500kb.

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

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

  4. 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.

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

Code below:

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.


回答1:


Maybe you forget click here when you add the resource?

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



来源:https://stackoverflow.com/questions/37957174/imessage-apps-programatically-create-animated-sticker-from-apng

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!