diff --git a/DropdownMenu/DropUpMenu.swift b/DropdownMenu/DropUpMenu.swift index bb78583..6daf213 100644 --- a/DropdownMenu/DropUpMenu.swift +++ b/DropdownMenu/DropUpMenu.swift @@ -20,6 +20,7 @@ public protocol DropUpMenuDelegate: class { func dropUpMenu(_ dropUpMenu: DropUpMenu, cellForRowAt indexPath: IndexPath) -> UITableViewCell? func dropUpMenu(_ dropUpMenu: DropUpMenu, didSelectRowAt indexPath: IndexPath) func dropUpMenuCancel(_ dropUpMenu: DropUpMenu) + func dropUpMenuWillDismiss(_ dropUpMenu: DropdownMenu) } public extension DropUpMenuDelegate { @@ -32,6 +33,9 @@ public extension DropUpMenuDelegate { func dropUpMenuCancel(_ dropUpMenu: DropUpMenu) { } + + func dropUpMenuWillDismiss(_ dropUpMenu: DropUpMenu) { + } } private let screenRect = UIScreen.main.bounds @@ -181,6 +185,7 @@ open class DropUpMenu: UIView { } open func hideMenu(isSelectAction: Bool = false) { + delegate?.dropUpMenuWillDismiss(self) UIView.animate(withDuration: animateDuration, animations: { self.backgroundColor = self.backgroudBeginColor self.tableView.frame.origin.y = screenRect.height - self.bottomOffsetY diff --git a/DropdownMenu/DropdownMenu.swift b/DropdownMenu/DropdownMenu.swift index 5eeb9e8..c3818d7 100644 --- a/DropdownMenu/DropdownMenu.swift +++ b/DropdownMenu/DropdownMenu.swift @@ -12,12 +12,14 @@ public protocol DropdownMenuDelegate: class { func dropdownMenu(_ dropdownMenu: DropdownMenu, cellForRowAt indexPath: IndexPath) -> UITableViewCell? func dropdownMenu(_ dropdownMenu: DropdownMenu, didSelectRowAt indexPath: IndexPath) func dropdownMenuCancel(_ dropdownMenu: DropdownMenu) + func dropdownMenuWillDismiss(_ dropdownMenu: DropdownMenu) } public extension DropdownMenuDelegate { func dropdownMenu(_ dropdownMenu: DropdownMenu, cellForRowAt indexPath: IndexPath) -> UITableViewCell? { return nil } func dropdownMenu(_ dropdownMenu: DropdownMenu, didSelectRowAt indexPath: IndexPath) { } func dropdownMenuCancel(_ dropdownMenu: DropdownMenu) { } + func dropdownMenuWillDismiss(_ dropdownMenu: DropdownMenu) { } } open class DropdownMenu: UIView { @@ -234,6 +236,7 @@ open class DropdownMenu: UIView { } open func hideMenu(isSelectAction: Bool = false) { + delegate?.dropdownMenuWillDismiss(self) UIView.animate(withDuration: animateDuration, animations: { self.backgroundColor = self.backgroudBeginColor self.tableView.frame.origin.y = -self.tableViewHeight