UIImage.swift 713 B

12345678910111213141516171819202122232425262728
  1. //
  2. // UIImage.swift
  3. // LoopKitUI
  4. //
  5. // Created by Nathaniel Hamming on 2020-07-15.
  6. // Copyright © 2020 LoopKit Authors. All rights reserved.
  7. //
  8. import UIKit
  9. private class LocalBundle {
  10. /// Returns the resource bundle associated with the current Swift module.
  11. static var main: Bundle = {
  12. if let mainResourceURL = Bundle.main.resourceURL,
  13. let bundle = Bundle(url: mainResourceURL.appendingPathComponent("LoopKitUI_LoopKitUI.bundle"))
  14. {
  15. return bundle
  16. }
  17. return Bundle(for: LocalBundle.self)
  18. }()
  19. }
  20. extension UIImage {
  21. convenience init?(frameworkImage name: String) {
  22. self.init(named: name, in: LocalBundle.main, with: nil)
  23. }
  24. }