Created
November 16, 2017 10:25
-
-
Save Tulakshana/84aa9165b18e544ff99b847c30be7d19 to your computer and use it in GitHub Desktop.
An UIView extension with a method to return the frame of the first responder.
This file contains hidden or 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
extension UIView { | |
func frameOfFirstResponder() -> CGRect? { | |
if self.isFirstResponder { | |
return self.frame | |
} | |
for view in self.subviews { | |
if let frame = view.frameOfFirstResponder() { | |
return frame | |
} | |
} | |
return nil | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment