7

I implemented the share extension and I want animate my View Controller with a crossDissolve, so i set the modalPresentationStyle = .overFullScreen and modalTransitionStyle = crossDissolve but it seems not working. The VC still appear from the bottom to the top and with the new iOS 13 modal style (not completly full screen). Anyone know how to solve it? It tried both with and without storyboard.

NB: I'm not talking about a normal VC presentation, but the presentation of the share extension, it means that it's another app that present my VC.

Fab
  • 816
  • 8
  • 17
  • I recreated this issue and I was, in fact, getting a cross dissolve and not the behavior you are describing. How are you presenting? Are you calling `present(_:animated:completion:)` or are you using segues via the interface builder? Can you show us any code? – David Chopin Oct 13 '19 at 22:02
  • This is an example of how I am able to get it to work: https://pastebin.com/Uz63Ckij – David Chopin Oct 13 '19 at 22:04
  • @DavidChopin It's the app that share the file that presents my `extension` so I don't know which presenting method it's used. (Ex: go to `Voice memos` and press `share` and I select my app). I just select the `modalPresentationStyle` and `modalTransitionStyle` on the properties of my VC. Your example is just a normal presentation. – Fab Oct 13 '19 at 22:07
  • Ah, I see now. Can you share some code of how you're implementing this? – David Chopin Oct 13 '19 at 22:11
  • any updates on this please ? – Ankit Mehta Oct 23 '19 at 10:32
  • @AnkitMehta No, I coudn't find a solution (even i saw that in some apps like Whatsapp and Telegram it works) – Fab Oct 29 '19 at 16:42
  • We've got the same issue. What version of Xcode are you building with? – GPRyan Dec 03 '19 at 18:24
  • I'm seeing the same issue, I've tried everything that I could think of and the Share Extension is **always** presented modally with the .coverVertical animation. I've even tried to do stuff like this on the UIViewController subclass that I'm using and it's called, but still doesn't work: `override var modalPresentationStyle: UIModalPresentationStyle { set { } get { .fullScreen } } override var modalTransitionStyle: UIModalTransitionStyle { set { } get { .crossDissolve } }` – Xavi Moll Dec 25 '19 at 17:59
  • @XaviMoll the strange things is that i found app where the presentation is different but i don't know how they do it – Fab Jan 06 '20 at 16:51
  • @Fab maybe those apps were not build with the iOS 13 SDK, thus using the old presentation behavior? – Greg de J Jan 10 '20 at 10:27
  • I believe that @GregdeJ is right, everything compiled with the iOS13 SDK seems to be presented modally no matter what, and with a background view that has some color (a very translucent grey) that you can't modify. I've started seeing some apps that have opted to fill the whole screen on the share extension now when before iOS13 they only filled part, I guess that it's to avoid having that translucent grey being shown. – Xavi Moll Feb 12 '20 at 09:36

1 Answers1

1

One way to do it would be to have the system presented viewcontroller as a container.

And then present your content viewcontroller inside modally.

// this is the entry point
// either the initial viewcontroller inside the extensions storyboard
// or
// the one you specify in the .plist file
class ContainerVC: UIViewController {

    // afaik presenting in viewDidLoad/viewWillAppear is not a good idea, but this produces the exact result you are looking for.
    // meaning the content slides up when extension is triggered.
    override func viewWillAppear() {
        super.viewWillAppear()

        view.backgroundColor = .clear

        let vc = YourRootVC()
        vc.view.backgroundColor = .clear
        vc.modalPresentationStyle = .overFullScreen
        vc.loadViewIfNeeded()
        present(vc, animated: false, completion: nil)
    }

}

and then use the content viewcontroller to show your root viewcontroller and its view hierarchy.

class YourRootVC: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        let vc = UIViewController() // your actual content
        vc.view.backgroundColor = .blue
        vc.view.frame = CGRect(origin: vc.view.center, size: CGSize(width: 200, height: 200))
        view.addSubview(vc.view)
        addChild(vc)
    }

}

Basically a container and a wrapper in order to get the control over the views being displayed.

Source: I had the same problem. This solution works for me.

iOS Blacksmith
  • 147
  • 1
  • 10