Reputation: 51
When I create a MSStickerBrowserViewController subclass by embedding it in a container view (using a storyboard) as the documentation suggests, I appear to have no opportunity to set the stickerSize. The Sticker Browser VC is initialized with init(coder:), and I have no way that I can see to override the get-only property stickerSize. I can only get stickerSize = MSStickerSize.regular.
I don't see any control in interface builder to configure the property either, though the documentation says "You can also customize the size of the stickers inside the browser."
Thanks to shallowThought, I see that an initializer is available init(stickerSize: MSStickerSize) on MSStickerBrowserViewController, but so far I have been unable to find a way to trigger that initializer when using a storyboard and overriding the required init(coder:) initializer.
Am i missing something?
Thanks!
Upvotes: 3
Views: 468
Reputation: 786
This worked for me: I added stickerSize
to the "User Defined Runtime Attributes" section of the Identity Inspector.
In this example, PetStickerBrowserViewController is a subclass of MSBrowserStickerViewController
. stickerSize
is set to 0, which corresponds to MSStickerSize.small
.
At runtime, when the view controller is instantiated from the storyboard, its stickerSize
property is set to .small
. Use 1 for .regular
(the default), and 2 for .large
.
Upvotes: 5
Reputation: 19602
You can set it when initializing.
StickerBroweserView
init(frame: CGRect, stickerSize: MSStickerSize)
Creates a new sticker browser containing stickers of the specified size.
StickerBroweserViewController
init(stickerSize: MSStickerSize)
Creates a new sticker browser view controller with stickers of the provided size.
To subclass it, implement the corresponding init
ializers.
I can not see a way to call init(stickerSize: MSStickerSize)
by somehow chaining init
calls from required init?(coder aDecoder: NSCoder)
, so you might have to instantiate the viewControllers programmatically.
Upvotes: 1