AppUtility.swift 857 B

1234567891011121314151617181920212223242526272829
  1. //
  2. // AppUtility.swift
  3. // Sirani
  4. //
  5. // Created by Anhar Solehudin on 19/04/19.
  6. // Copyright © 2019 Anhar Solehudin. All rights reserved.
  7. //
  8. import UIKit
  9. struct AppUtility {
  10. static func lockOrientation(_ orientation: UIInterfaceOrientationMask) {
  11. if let delegate = UIApplication.shared.delegate as? AppDelegate {
  12. delegate.orientationLock = orientation
  13. }
  14. }
  15. /// OPTIONAL Added method to adjust lock and rotate to the desired orientation
  16. static func lockOrientation(_ orientation: UIInterfaceOrientationMask, andRotateTo rotateOrientation:UIInterfaceOrientation) {
  17. self.lockOrientation(orientation)
  18. UIDevice.current.setValue(rotateOrientation.rawValue, forKey: "orientation")
  19. UINavigationController.attemptRotationToDeviceOrientation()
  20. }
  21. }