Last active
December 9, 2015 21:41
-
-
Save Pretz/10b4b11806263b556761 to your computer and use it in GitHub Desktop.
Gets the info from a UIKeyboardWill(Show/Hide)Notification and returns it in a not-terrible tuple
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
public func keyboardInfoFromUserInfo(userInfo: [NSObject: AnyObject]) -> (beginFrame: CGRect, endFrame: CGRect, animationCurve: UIViewAnimationOptions, animationDuration: Double)? { | |
if let beginFrameValue = userInfo[UIKeyboardFrameBeginUserInfoKey] as? NSValue, | |
let endFrameValue = userInfo[UIKeyboardFrameEndUserInfoKey] as? NSValue, | |
let animationCurve = userInfo[UIKeyboardAnimationCurveUserInfoKey] as? NSNumber, | |
let animationDuration = userInfo[UIKeyboardAnimationDurationUserInfoKey] as? NSNumber { | |
return ( | |
beginFrame: beginFrameValue.CGRectValue(), | |
endFrame: endFrameValue.CGRectValue(), | |
animationCurve: UIViewAnimationOptions(rawValue: animationCurve.unsignedIntegerValue << 16), | |
animationDuration: animationDuration.doubleValue) | |
} | |
return nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment