@@ -28,10 +28,10 @@ internal extension UIApplication {
2828 static func getTopViewController( base: UIViewController ? = UIApplication . shared. keyWindow? . rootViewController) -> UIViewController ? {
2929 if let nav = base as? UINavigationController {
3030 return getTopViewController ( base: nav. visibleViewController)
31-
31+
3232 } else if let tab = base as? UITabBarController , let selected = tab. selectedViewController {
3333 return getTopViewController ( base: selected)
34-
34+
3535 } else if let presented = base? . presentedViewController {
3636 return getTopViewController ( base: presented)
3737 }
@@ -61,7 +61,7 @@ extension UIView {
6161 /// True if there is currently a tooltip presented that has the calling view as `presentingView`.
6262 public var hasActiveTooltip : Bool {
6363 guard let activeTooltips = UIApplication . shared. keyWindow? . subviews. filter ( { $0 is Tooltip } ) ,
64- !activeTooltips. isEmpty else { return false }
64+ !activeTooltips. isEmpty else { return false }
6565
6666 return activeTooltips. compactMap { $0 as? Tooltip } . contains ( where: { $0. presentingView == self } )
6767 }
@@ -93,7 +93,7 @@ extension UIView {
9393 label. numberOfLines = 0
9494 label. text = text
9595 label. preferredMaxLayoutWidth = configuration. labelConfiguration. preferredMaxLayoutWidth
96-
96+
9797 let toolTip = Tooltip ( view: label, presentingView: self , orientation: orientation, configuration: configuration)
9898
9999 UIApplication . shared. keyWindow? . addSubview ( toolTip)
@@ -171,4 +171,14 @@ extension UIBarItem {
171171 }
172172}
173173
174+ extension Tooltip {
175+ /// Dismisses all tooltips that are currently shown on any sub view in the `keyWindow`.
176+ public static func dismissAll( ) {
177+ guard let activeTooltips = UIApplication . shared. keyWindow? . subviews. filter ( { $0 is Tooltip } ) ,
178+ !activeTooltips. isEmpty else { return }
179+
180+ activeTooltips. compactMap { $0 as? Tooltip } . forEach { $0. dismiss ( ) }
181+ }
182+ }
183+
174184#endif
0 commit comments