Last active
January 4, 2016 00:09
-
-
Save Cheesebaron/8539458 to your computer and use it in GitHub Desktop.
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
private NSObject _notification; | |
private float _scrollAmount; | |
private double _animationDuration; | |
private UIViewAnimationCurve _animationCurve; | |
public override void ViewDidLoad() | |
{ | |
... | |
_notification = UIKeyboard.Notifications.ObserveWillShow((s, e) => | |
{ | |
_animationDuration = e.AnimationDuration; | |
_animationCurve = e.AnimationCurve; | |
var r = UIKeyboard.FrameBeginFromNotification(e.Notification); | |
_scrollAmount = r.Height; | |
ScrollTheView(true); | |
}); | |
} | |
private void ScrollTheView(bool scale) | |
{ | |
UIView.BeginAnimations(string.Empty, IntPtr.Zero); | |
UIView.SetAnimationDuration(_animationDuration); | |
UIView.SetAnimationCurve(_animationCurve); | |
var frame = View.Frame; | |
if (scale) | |
frame.Height -= _scrollAmount; | |
else | |
frame.Height += _scrollAmount; | |
View.Frame = frame; | |
UIView.CommitAnimations(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment