mintyLemon
mintyLemon

Reputation: 35

iMessage Extension: Callback when switching view (compact/enlarge)

In my iMessage Extension, I am displaying stickers to the user, which are only displayed correctly, when the MSStickerView has the correct size. I resize it using sizeToFit(). However, switching between views changes its size to the maximum possible. Is there a function called whenever the switch button is pressed that I can add my code into and can you point me to the function that actually does the maximum resizing when switching (the one I do not want)?

Upvotes: 0

Views: 283

Answers (1)

Dean
Dean

Reputation: 1542

You need to override func didTransition(to: MSMessagesAppPresentationStyle)

It will be called when the presentation has finished changed.

override func didTransition(to: MSMessagesAppPresentationStyle) {
    super.didTransition(to: to)

    switch to {
    case .compact:
        // Do your compact presentation
        break
    case .expanded:
        // Do your expanded presentation
        break
}

API reference : https://developer.apple.com/documentation/messages/msmessagesappviewcontroller/1649192-didtransition

Upvotes: 1

Related Questions