-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from FranklinSamboni/dropdown-toggle
Dropdown toggle
- Loading branch information
Showing
3 changed files
with
93 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// | ||
// UIWindowExtension.swift | ||
// CustomDropDown | ||
// | ||
// Created by Franklin Samboni on 26/10/20. | ||
// Copyright © 2020 Amirthy Tejeshwar. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
extension UIWindow { | ||
func topViewController() -> UIViewController? { | ||
var top = self.rootViewController | ||
while true { | ||
if let presented = top?.presentedViewController { | ||
top = presented | ||
} else if let nav = top as? UINavigationController { | ||
top = nav.visibleViewController | ||
} else if let tab = top as? UITabBarController { | ||
top = tab.selectedViewController | ||
} else { | ||
break | ||
} | ||
} | ||
return top | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters