diff --git a/Sources/Earthquake Network.xcodeproj/project.pbxproj b/Sources/Earthquake Network.xcodeproj/project.pbxproj index a1ecf54..61e7fdd 100644 --- a/Sources/Earthquake Network.xcodeproj/project.pbxproj +++ b/Sources/Earthquake Network.xcodeproj/project.pbxproj @@ -137,6 +137,7 @@ 65BBB22C26064BE6005D6CDF /* SegnalazioniLast24HoursCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65BBB22B26064BE6005D6CDF /* SegnalazioniLast24HoursCell.swift */; }; 65CB83432915720400EE1E35 /* EQNUserData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65CB83422915720400EE1E35 /* EQNUserData.swift */; }; 65D409942619BA34008CF356 /* SegnalazioniSendReportCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65D409932619BA34008CF356 /* SegnalazioniSendReportCell.swift */; }; + 65D9938A29219DEC00F2B0EB /* UIKit+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65583A04261B83BE00ECA9F9 /* UIKit+Extensions.swift */; }; 65DBFB4B25E29DD60041CBA6 /* SeismicNetworksMapDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65DBFB4A25E29DD60041CBA6 /* SeismicNetworksMapDetailViewController.swift */; }; 65DBFB7425E2BBF20041CBA6 /* GADTMediumTemplateView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 65DBFB6F25E2BBF20041CBA6 /* GADTMediumTemplateView.xib */; }; 65DBFB7525E2BBF20041CBA6 /* GADTMediumTemplateView.m in Sources */ = {isa = PBXBuildFile; fileRef = 65DBFB7125E2BBF20041CBA6 /* GADTMediumTemplateView.m */; }; @@ -1680,6 +1681,7 @@ 653C67E625F3CC8400FE52AC /* EQNCustomAnnotationView.swift in Sources */, 654D18DA25F9424700BB6DB0 /* EQNUtility+Extensions.swift in Sources */, DC0AE1BA2538204100111307 /* EQNPastquakes.m in Sources */, + 65D9938A29219DEC00F2B0EB /* UIKit+Extensions.swift in Sources */, 8CF12CD921DE49B600613AC5 /* NotificationViewController.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/Sources/Earthquake Network/Controllers/Seismic Networks/Cells/SeismicNetworkTableViewCell.swift b/Sources/Earthquake Network/Controllers/Seismic Networks/Cells/SeismicNetworkTableViewCell.swift index 8b140ad..62a42e4 100644 --- a/Sources/Earthquake Network/Controllers/Seismic Networks/Cells/SeismicNetworkTableViewCell.swift +++ b/Sources/Earthquake Network/Controllers/Seismic Networks/Cells/SeismicNetworkTableViewCell.swift @@ -505,16 +505,6 @@ class SeismicNetworkTableViewCell: UITableViewCell { updateUI() } - /// Creates a snapshot of the current cell - /// - Returns: Image with the snapshot of the cell - public func createSnapshot() -> UIImage { - let renderer = UIGraphicsImageRenderer(size: contentView.bounds.size) - let image = renderer.image { ctx in - contentView.drawHierarchy(in: contentView.bounds, afterScreenUpdates: true) - } - return image - } - // MARK: - Actions @objc func shareTapped(_ sender: UIButton) { diff --git a/Sources/Earthquake Network/Controllers/Seismic Networks/SeismicNetworksViewController.swift b/Sources/Earthquake Network/Controllers/Seismic Networks/SeismicNetworksViewController.swift index 77cbb57..5b40ce0 100644 --- a/Sources/Earthquake Network/Controllers/Seismic Networks/SeismicNetworksViewController.swift +++ b/Sources/Earthquake Network/Controllers/Seismic Networks/SeismicNetworksViewController.swift @@ -317,7 +317,7 @@ extension SeismicNetworksViewController: SeismicNetworkTableViewCellDelegate { guard let index = tableView?.indexPath(for: cell), case let .seismic(seismic) = rows[index.row] else { return } // create a snapshot of the cell and share with default share sheet - let snapshot = cell.createSnapshot() + let snapshot = cell.contentView.createSnapshot() // text to share with the snapshot let shareHashtag = NSLocalizedString("share_hashtag", comment: "") diff --git a/Sources/Earthquake Network/Libs/Extensions/UIKit+Extensions.swift b/Sources/Earthquake Network/Libs/Extensions/UIKit+Extensions.swift index bc4cb3a..2b4ec91 100644 --- a/Sources/Earthquake Network/Libs/Extensions/UIKit+Extensions.swift +++ b/Sources/Earthquake Network/Libs/Extensions/UIKit+Extensions.swift @@ -22,3 +22,16 @@ extension UIButton { setTitle(title, for: .normal) } } + + +extension UIView { + /// Creates a snapshot of the current view + /// - Returns: Image with the snapshot of the view + public func createSnapshot() -> UIImage { + let renderer = UIGraphicsImageRenderer(size: bounds.size) + let image = renderer.image { ctx in + drawHierarchy(in: bounds, afterScreenUpdates: true) + } + return image + } +}