這是你下面要什麼。這是從選項卡視圖轉換而來的。希望這將幫助一些人:
protected void HandleLeftSwipe(UISwipeGestureRecognizer recognizer)
{
if (this.TabBarController.SelectedIndex != 4) {
UIView fromView = this.TabBarController.SelectedViewController.View;
UIView toView = this.TabBarController.ViewControllers[this.TabBarController.SelectedIndex+1].View;
// Get the size of the view area.
var viewSize = fromView.Frame;
// Add the to view to the tab bar view.
fromView.Superview.AddSubview (toView);
var minAlpha = -320.0;
var maxAlpha = 320.0;
var midAlpha =0.0;
// Position it off screen.
toView.Frame = new CGRect (maxAlpha , viewSize.Y, maxAlpha, viewSize.Height);
UIView.Animate (.3,.1, UIViewAnimationOptions.CurveEaseOut ,
() => {
fromView.Frame = new CGRect (minAlpha , viewSize.Y, maxAlpha, viewSize.Height);
toView.Frame =new CGRect (midAlpha, viewSize.Y, maxAlpha, viewSize.Height);
},
() => {
fromView.RemoveFromSuperview();
this.TabBarController.SelectedIndex = this.TabBarController.SelectedIndex + 1;
}
);
}
}
protected void HandleRightSwipe(UISwipeGestureRecognizer recognizer)
{
if (this.TabBarController.SelectedIndex != 0) {
UIView fromView = this.TabBarController.SelectedViewController.View;
UIView toView = this.TabBarController.ViewControllers[this.TabBarController.SelectedIndex-1].View;
// Get the size of the view area.
var viewSize = fromView.Frame;
// Add the to view to the tab bar view.
fromView.Superview.AddSubview (toView);
var minAlpha = -320.0;
var maxAlpha = 320.0;
var midAlpha =0.0;
// Position it off screen.
toView.Frame = new CGRect (minAlpha , viewSize.Y, maxAlpha, viewSize.Height);
UIView.Animate (.3,.1, UIViewAnimationOptions.CurveEaseOut ,
() => {
fromView.Frame = new CGRect (maxAlpha , viewSize.Y, maxAlpha, viewSize.Height);
toView.Frame =new CGRect (midAlpha, viewSize.Y, maxAlpha, viewSize.Height);
},
() => {
fromView.RemoveFromSuperview();
this.TabBarController.SelectedIndex = this.TabBarController.SelectedIndex - 1;
}
);
}
}