SwiftWebVCActivity.swift 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. //
  2. // SwiftWebVCActivity.swift
  3. //
  4. // Created by Myles Ringle on 24/06/2015.
  5. // Transcribed from code used in SVWebViewController.
  6. // Copyright (c) 2015 Myles Ringle & Sam Vermette. All rights reserved.
  7. //
  8. import UIKit
  9. class SwiftWebVCActivity: UIActivity {
  10. var URLToOpen: URL?
  11. var schemePrefix: String?
  12. override var activityType : UIActivity.ActivityType? {
  13. let typeArray = "\(Swift.type(of: self))".components(separatedBy: ".")
  14. let type: String = typeArray[typeArray.count-1]
  15. return UIActivity.ActivityType(rawValue: type)
  16. }
  17. override var activityImage : UIImage {
  18. if let type = activityType?.rawValue {
  19. if (UIDevice.current.userInterfaceIdiom == UIUserInterfaceIdiom.pad) {
  20. return SwiftWebVC.bundledImage(named: "\(type)-iPad")!
  21. }
  22. else {
  23. return SwiftWebVC.bundledImage(named: "\(type)")!
  24. }
  25. }
  26. else{
  27. assert(false, "Unknow type")
  28. return UIImage()
  29. }
  30. }
  31. override func prepare(withActivityItems activityItems: [Any]) {
  32. for activityItem in activityItems {
  33. if activityItem is URL {
  34. URLToOpen = activityItem as? URL
  35. }
  36. }
  37. }
  38. }