diff --git a/CRNotifications/Classes/CRNotification.swift b/CRNotifications/Classes/CRNotification.swift index e694011..3010c03 100644 --- a/CRNotifications/Classes/CRNotification.swift +++ b/CRNotifications/Classes/CRNotification.swift @@ -93,6 +93,9 @@ class CRNotification: UIView { NotificationCenter.default.addObserver(self, selector: #selector(didRotate), name: NSNotification.Name.UIDeviceOrientationDidChange, object: nil) let dismissRecognizer = UITapGestureRecognizer(target: self, action: #selector(self.dismissNotification)) addGestureRecognizer(dismissRecognizer) + let swipeRecognizer = UISwipeGestureRecognizer(target: self, action: #selector(self.dismissNotification)) + swipeRecognizer.direction = .up + addGestureRecognizer(swipeRecognizer) } @objc func didRotate() { diff --git a/CRNotifications/Classes/CRNotifications.swift b/CRNotifications/Classes/CRNotifications.swift index 4f718f9..cc5006f 100644 --- a/CRNotifications/Classes/CRNotifications.swift +++ b/CRNotifications/Classes/CRNotifications.swift @@ -12,16 +12,20 @@ public class CRNotifications { public init(){} - /// Shows a CRNotification - public static func showNotification(type: CRNotificationType, title: String, message: String, dismissDelay: TimeInterval, completion: @escaping () -> () = {}) { + /** Shows a CRNotification with a type, title, message, delay and completion callback */ + public static func showNotification(type: CRNotificationType, title: String, message: String, dismissDelay: TimeInterval, completion: @escaping () -> () = {}) { + showNotification(type: type, title: title, message: message, dismissDelay: dismissDelay, backgroundColor: type.color, completion: completion) + } + /** Shows a CRNotification with a type, title, message, delay, background color and completion callback */ + public static func showNotification(type: CRNotificationType, title: String, message: String, dismissDelay: TimeInterval, backgroundColor: UIColor, completion: @escaping () -> () = {}) { let view = CRNotification() - view.setBackgroundColor(color: type.color) + view.setBackgroundColor(color: backgroundColor) view.setImage(image: type.image) view.setTitle(title: title) view.setMessage(message: message) view.setDismisTimer(delay: dismissDelay) - view.setCompletionBlock(completion) + view.setCompletionBlock(completion) guard let window = UIApplication.shared.keyWindow else { print("Failed to show CRNotification. No keywindow available.")