5

I have a sticker package Stickers.xcstickers with a few stickers in it. I would like to programmatically get one of these stickers and put it in a MSStickerView that I have in a UICollectionViewCell. I know with a UIImage it is easy and you can just do

let myImage = UIImage(named: "myImage.jpg")

Is there an equivalent to this with MSSticker?

let mySticker = MSSticker(named: "mySticker") obviously does not work.

There is MSSticker(contentsOfFileURL: URL, localizedDescription: String but I am unsure how to, if possible, properly implement in a similar fashion to UIImage.

Thanks.

DerFlickschter
  • 1,059
  • 1
  • 9
  • 18

2 Answers2

3

No, there is not currently an equivalent. Moreover, you cannot programmatically create stickers from images in an asset catalog either, since those aren't accessible through file URL (pathForResource on the bundle won't generate a path for items in an .xcassets folder).

You need to go old school and drag the images in as a resource like you would any other file you were adding to the project.

JAB
  • 3,165
  • 16
  • 29
0

BJHStudios is right, unfortunately! I recently answered another question that you may want to take a look at. It goes over everything you need to get your stickers onto the BrowserView with the MSSticker(contentsOfFileURL: URL, localizedDescription: String) method.

Link to other question

Jake Dobson
  • 1,716
  • 3
  • 11
  • 29
  • With a bit more rep, [you will be able to flag duplicate questions like this](https://stackoverflow.com/privileges/comment). Until then, posting links as answers is not really ideal, and they will generally be deleted. Or, if the question is not a duplicate, *tailor the answer to this specific question*. – Nathan Tuggy Jun 08 '17 at 01:37
  • So what am I supposed to do? Not answer the question for the world to see!? Copy the same answer and literally turn it into a duplicate question? I can't comment yet, either. – Jake Dobson Jun 08 '17 at 22:00
  • If you can't flag (yet), and there's no differences, then yes, please do refrain from answering. – Nathan Tuggy Jun 08 '17 at 22:12