UiUtils.swift 742 B

123456789101112131415
  1. // Copyright 2019-2024 Tauri Programme within The Commons Conservancy
  2. // SPDX-License-Identifier: Apache-2.0
  3. // SPDX-License-Identifier: MIT
  4. import UIKit
  5. public class UIUtils {
  6. public static func centerPopover(rootViewController: UIViewController?, popoverController: UIViewController) {
  7. if let viewController = rootViewController {
  8. popoverController.popoverPresentationController?.sourceRect = CGRect(x: viewController.view.center.x, y: viewController.view.center.y, width: 0, height: 0)
  9. popoverController.popoverPresentationController?.sourceView = viewController.view
  10. popoverController.popoverPresentationController?.permittedArrowDirections = UIPopoverArrowDirection.up
  11. }
  12. }
  13. }