Created
August 24, 2016 22:14
-
-
Save tomasdev/95ee382d886b0fad25f9c5a659a1d5db to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class StickerBrowserViewController: MSStickerBrowserViewController { | |
let stickerNames = ["piggie_cute", "piggie_bowing", "piggie_waving", "piggie_crying", "piggie_laughing", "piggie_winking", "professor_pig", "piggie_cheering", "piggie_scorning", "piggie_swooning", "wtf", "870194"] | |
var stickers = [MSSticker]() | |
weak var delegate: StickerBrowserViewControllerDelegate? | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
loadStickers() | |
} | |
override var stickerSize: MSStickerSize { | |
get { | |
return .regular | |
} | |
} | |
func loadStickers() { | |
stickers = stickerNames.map( {name in | |
let url = Bundle.main.url(forResource: name, withExtension: "png")! | |
return try! MSSticker(contentsOfFileURL: url, localizedDescription: name) | |
}) | |
} | |
} | |
extension StickerBrowserViewController { | |
override func numberOfStickers(in stickerBrowserView: MSStickerBrowserView) -> Int { | |
return stickers.count | |
} | |
override func stickerBrowserView(_ stickerBrowserView: MSStickerBrowserView, stickerAt index: Int) -> MSSticker { | |
return stickers[index] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment