需要对输入框进行监听,然后用动画将当期视图进行上移.
NSNotificationCenter.DefaultCenter.AddObserver (UITextView.TextDidBeginEditingNotification, (notity) => {
InvokeOnMainThread (() => {
//Tools.Alert ("do");
UIView.BeginAnimations ("answerviewanimation2");
this.View.Center = new PointF (rf.Width / 2, rf.Height / 2 - 215);
UIView.CommitAnimations ();
});
});
/// <summary>
/// 隐藏键盘
/// </summary>
public override void TouchesBegan (NSSet touches, UIEvent evt)
{
base.TouchesBegan (touches, evt);
UITouch touch = touches.AnyObject as UITouch;
if (touch != null) {
if (!utxt.Frame.Contains (touch.LocationInView (this.View))) {
utxt.ResignFirstResponder ();
//视图下移
UIView.BeginAnimations ("answerviewanimation2");
float _t = Tools.IsSdk7 () ? 0 : 44;
this.View.Center = new PointF (rf.Width / 2, (rf.Height + 44) / 2 - _t);
UIView.CommitAnimations ();
}
}
}