swift3 - Animated iMessage App Graphics -
i'm creating own imessage custom app , want send imessage background swaps between 2 images, therefore creating illusion of animation. i'm not sure possible i'm trying code below. code shows first image when message received recipient. appreciated.
func createimageformessage() -> uiimage? { let cupanimation = uiimageview(frame: cgrect(x: 0, y: 0, width: 300, height: 300)) let imageslistarray = [uiimage(named: "boy_cup_1_1.png")!,uiimage(named: "boy_cup_1_7.png")!] cupanimation.animationimages = imageslistarray cupanimation.animationduration = 10.0 cupanimation.animationrepeatcount = 50 cupanimation.startanimating() let cupbackground = uiview(frame: cgrect(x: 0, y: 0, width: 300, height: 300)) cupbackground.addsubview(cupanimation) background.addsubview(cupbackground) background.frame.origin = cgpoint(x: view.frame.size.width, y: view.frame.size.height) view.addsubview(background) uigraphicsbeginimagecontextwithoptions(background.frame.size, false, uiscreen.main.scale) background.drawhierarchy(in: background.bounds, afterscreenupdates: true) let image = uigraphicsgetimagefromcurrentimagecontext() uigraphicsendimagecontext() background.removefromsuperview() return image }
rich messaging extensions imessage come in 2 kinds: imessage apps , sticker packs.
when have imessage app, custom message content create in app (and send via
msmessage
ormssession
) can viewed recipient only if have imessage app installed. if don't, receive static preview of content, along ui lets recipient install app app store.when have sticker pack, there's no code involved in creating sticker images — they're assets. apple's imessage service can pass assets on device, , can view them regardless of whether have app installed on device. (and regardless of whether could have app installed. custom sticker apps can installed on ios, macos , watchos can receive stickers.)
so, have animated stickers, need create animated assets. preferred format apng, , there's support in xcode automatically creating apng animated stickers sequences of png images — in editor xcstickers
bundle. or follow along tutorials , videos on creating stickers imessage on apple developer site.
note can combine 2 — can have imessage app dynamically creates new stickers mssticker
class , sends them other users. in case, stickers dynamic in app creating them @ runtime, after creation they're static assets, means imessage service can distribute them , recipients don't need app installed view them.
if create stickers dynamically you'll need write sticker asset file in app before passing mssticker
class. if you're doing animated images, can create apng file using cgimagedestination
api — see this bit in apple's image i/o programming guide.
the above attempt answer seems actual topic of question — sending animated stickers in imessage. you've got more specific confusion in code, here's attempt address that...
your method returns uiimage
. class doesn't support animations, static images. if want animation, you'll need different represent 1 (as seen cgimagedestination
above).
uiimageview
can present animations being given sequence of uiimage
s. when use drawhierarchy(in:afterscreenupdates:)
you're taking screenshot of view, creating single static image.
Comments
Post a Comment