Customize iOS share extension UI

It is common to extend SLComposeServiceViewController to build a share extension UI. If you prefer a different UI, you can follow the below steps.

  1. Create a new UIViewController rather than extending SLComposeServiceViewController, and you need to add @objc (CustomShareViewController)

    @objc (CustomShareViewController)
    class CustomShareViewController: UIViewController
  2. Create a UI, and remember that you cannot present or show another view controller. If you want to show different UI, you can use alpha to show or hide UI elements.

  3. Remember to use extensionContext!.cancelRequest(withError: NSError()) or extensionContext!.completeRequest(returningItems: [], completionHandler: nil) to close UI