diff --git a/DropdownMenu/DropUpMenu.swift b/DropdownMenu/DropUpMenu.swift index 6daf213..db3d4b3 100644 --- a/DropdownMenu/DropUpMenu.swift +++ b/DropdownMenu/DropUpMenu.swift @@ -20,7 +20,8 @@ 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) + func dropUpMenuWillDismiss(_ dropUpMenu: DropUpMenu) + func dropUpMenuWillShow(_ dropUpMenu: DropUpMenu) } public extension DropUpMenuDelegate { @@ -28,14 +29,13 @@ public extension DropUpMenuDelegate { return nil } - func dropUpMenu(_ dropUpMenu: DropUpMenu, didSelectRowAt indexPath: IndexPath) { - } + func dropUpMenu(_ dropUpMenu: DropUpMenu, didSelectRowAt indexPath: IndexPath) { } - func dropUpMenuCancel(_ dropUpMenu: DropUpMenu) { - } + func dropUpMenuCancel(_ dropUpMenu: DropUpMenu) { } - func dropUpMenuWillDismiss(_ dropUpMenu: DropUpMenu) { - } + func dropUpMenuWillDismiss(_ dropUpMenu: DropUpMenu) { } + + func dropUpMenuWillShow(_ dropUpMenu: DropUpMenu) { } } private let screenRect = UIScreen.main.bounds @@ -152,6 +152,7 @@ open class DropUpMenu: UIView { } open func showMenu() { + delegate?.dropUpMenuWillShow(self) if isShow { hideMenu() return diff --git a/DropdownMenu/DropdownMenu.swift b/DropdownMenu/DropdownMenu.swift index c3818d7..c0b1299 100644 --- a/DropdownMenu/DropdownMenu.swift +++ b/DropdownMenu/DropdownMenu.swift @@ -13,6 +13,7 @@ public protocol DropdownMenuDelegate: class { func dropdownMenu(_ dropdownMenu: DropdownMenu, didSelectRowAt indexPath: IndexPath) func dropdownMenuCancel(_ dropdownMenu: DropdownMenu) func dropdownMenuWillDismiss(_ dropdownMenu: DropdownMenu) + func dropdownMenuWillShow(_ dropdownMenu: DropdownMenu) } public extension DropdownMenuDelegate { @@ -20,6 +21,7 @@ public extension DropdownMenuDelegate { func dropdownMenu(_ dropdownMenu: DropdownMenu, didSelectRowAt indexPath: IndexPath) { } func dropdownMenuCancel(_ dropdownMenu: DropdownMenu) { } func dropdownMenuWillDismiss(_ dropdownMenu: DropdownMenu) { } + func dropdownMenuWillShow(_ dropdownMenu: DropdownMenu) { } } open class DropdownMenu: UIView { @@ -36,7 +38,11 @@ open class DropdownMenu: UIView { fileprivate let portraitTopOffset: CGFloat = 64.0 fileprivate let landscapeTopOffset: CGFloat = 32.0 fileprivate var topLayoutConstraintConstant: CGFloat { - return navigationController.navigationBar.frame.height + navigationController.navigationBar.frame.origin.y + topOffsetY + var offset: CGFloat = 0 + if !navigationController.isNavigationBarHidden { + offset = navigationController.navigationBar.frame.height + navigationController.navigationBar.frame.origin.y + } + return offset + topOffsetY } open weak var delegate: DropdownMenuDelegate? @@ -197,6 +203,7 @@ open class DropdownMenu: UIView { } open func showMenu(isOnNavigaitionView: Bool = false) { + delegate?.dropdownMenuWillShow(self) if isShow { hideMenu() return diff --git a/TBDropdownMenu.podspec b/TBDropdownMenu.podspec index 404075c..cb58d69 100644 --- a/TBDropdownMenu.podspec +++ b/TBDropdownMenu.podspec @@ -16,7 +16,7 @@ Pod::Spec.new do |s| # s.name = "TBDropdownMenu" - s.version = "2.3.0" + s.version = "2.4.1" s.summary = "TBDropdownMenu is a dropdown menu for navigationController in Swift" # This description is used to generate tags and improve search results.