Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Animoji/Memoji as profile photo

Tags:

swift

memoji

I am building a profile section in my app. I want to enable the selection of Animoji/MeMoji for a profile picture (exactly like the contacts app permits as shown in the image here). enter image description here

Does anyone know if apple is planning to release an API for this or where I could find more information for building this functionality into our app? I think this would be a nice feature for our users.

like image 288
Mike Perhats Avatar asked Nov 06 '22 05:11

Mike Perhats


1 Answers

I have built very similar functionality in my application. I must say, it's one of my favorite things! There's no official API to this however, I've been able to accomplish a workaround to getting this to work by:

  1. Adding a textview which automatically sets in focus in viewWillAppear, and setting its alpha to zero
  2. Enabling allowsEditingTextAttributes on the textview to ensure the Memoji stickers show up in the keyboard
  3. Added a label describing how to get to the stickers for users
  4. On sticker selection the textViewDidChange delegate function is called, the OS adds an NSTextAttachment with the image.
  5. Once I get the image from the NSTextAttachment, I set it to an image view I have on the screen and reset the text on the textview

And you're done :D

like image 170
NSDavidObject Avatar answered Nov 15 '22 04:11

NSDavidObject