Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 10 Swift programmatically get sticker from Stickers.xcstickers

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.

like image 548
DerFlickschter Avatar asked Oct 19 '22 01:10

DerFlickschter


1 Answers

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.

like image 75
JAB Avatar answered Oct 21 '22 00:10

JAB