diff --git a/NativePopup.xcodeproj/project.pbxproj b/NativePopup.xcodeproj/project.pbxproj index 694d79e..1a06ee2 100644 --- a/NativePopup.xcodeproj/project.pbxproj +++ b/NativePopup.xcodeproj/project.pbxproj @@ -17,6 +17,7 @@ FECA87D91EAC87B700D07CB1 /* NativePopup.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FE85338B1EAC7C92004BB756 /* NativePopup.framework */; }; FECA87DA1EAC87B700D07CB1 /* NativePopup.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = FE85338B1EAC7C92004BB756 /* NativePopup.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; FECA87DF1EAC94B300D07CB1 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = FECA87DE1EAC94B300D07CB1 /* Assets.xcassets */; }; + FECA87E11EACC77800D07CB1 /* NativePopup.extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = FECA87E01EACC77800D07CB1 /* NativePopup.extension.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -56,6 +57,7 @@ FECA87C51EAC7CCF00D07CB1 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; FECA87D71EAC7D9E00D07CB1 /* NativePopup.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NativePopup.swift; sourceTree = ""; }; FECA87DE1EAC94B300D07CB1 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + FECA87E01EACC77800D07CB1 /* NativePopup.extension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NativePopup.extension.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -101,6 +103,7 @@ FE85338E1EAC7C92004BB756 /* NativePopup.h */, FE85338F1EAC7C92004BB756 /* Info.plist */, FECA87D71EAC7D9E00D07CB1 /* NativePopup.swift */, + FECA87E01EACC77800D07CB1 /* NativePopup.extension.swift */, FECA87DE1EAC94B300D07CB1 /* Assets.xcassets */, ); path = NativePopup; @@ -236,6 +239,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + FECA87E11EACC77800D07CB1 /* NativePopup.extension.swift in Sources */, FECA87D81EAC7D9E00D07CB1 /* NativePopup.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/NativePopup/NativePopup.extension.swift b/NativePopup/NativePopup.extension.swift new file mode 100644 index 0000000..c31263f --- /dev/null +++ b/NativePopup/NativePopup.extension.swift @@ -0,0 +1,41 @@ +// +// NativePopup.extension.swift +// NativePopup +// +// Created by mono on 2017/04/23. +// Copyright © 2017 mono. All rights reserved. +// + +import Foundation + +extension NativePopup { + public enum Image { + case + good, + bad, + custom(image: UIImage) + + var image: UIImage { + switch self { + case .good: return type(of: self).createImage(named: "good") + case .bad: return type(of: self).createImage(named: "bad") + case .custom(let image): return image + } + } + + private static func createImage(named: String) -> UIImage { + return UIImage.init(named: named, in: Bundle(for: NativePopup.self), compatibleWith: nil)! + } + } + + public struct Info { + public let image: Image + public let title: String + public let message: String? + public init(image: Image, title: String, message: String?) { + self.image = image + self.title = title + self.message = message + } + } +} diff --git a/NativePopup/NativePopup.swift b/NativePopup/NativePopup.swift index 63b0560..ba98720 100644 --- a/NativePopup/NativePopup.swift +++ b/NativePopup/NativePopup.swift @@ -9,42 +9,11 @@ import Foundation import UIKit - public class NativePopup: UIView { private static let keyWindow = UIApplication.shared.keyWindow! private weak static var currentView: NativePopup? - public enum Image { - case - good, - bad, - custom(image: UIImage) - - fileprivate var image: UIImage { - switch self { - case .good: return type(of: self).createImage(named: "good") - case .bad: return type(of: self).createImage(named: "bad") - case .custom(let image): return image - } - } - - private static func createImage(named: String) -> UIImage { - return UIImage.init(named: named, in: Bundle(for: NativePopup.self), compatibleWith: nil)! - } - } - - public struct Info { - public let image: Image - public let title: String - public let message: String? - public init(image: Image, title: String, message: String?) { - self.image = image - self.title = title - self.message = message - } - } - public static func show(info: Info) { let view = NativePopup(info: info) view.show()