Ios UIViewController自定义转换样式(由内向外表示)
我想制作一个自定义演示(推送或模式),以在我搜索过的“由内而外演示”中显示视图控制器,但大多数方法是从不同的方向(从右、从上)显示视图控制器而不是默认方向,但我需要的是,如果有任何解决方案,将包括viewController中的缩放功能。您可以实现自己的自定义Ios UIViewController自定义转换样式(由内向外表示),ios,iphone,xcode,ipad,xamarin.ios,Ios,Iphone,Xcode,Ipad,Xamarin.ios,我想制作一个自定义演示(推送或模式),以在我搜索过的“由内而外演示”中显示视图控制器,但大多数方法是从不同的方向(从右、从上)显示视图控制器而不是默认方向,但我需要的是,如果有任何解决方案,将包括viewController中的缩放功能。您可以实现自己的自定义UIViewControllerAnimatedTransitioning。这是C#中自定义圆淡入淡出(由内而外)过渡的示例(在swift中应该不难复制): 然后,您可以对UINavigationController进行子类化,并覆盖其Ge
UIViewControllerAnimatedTransitioning
。这是C#中自定义圆淡入淡出(由内而外)过渡的示例(在swift中应该不难复制):
然后,您可以对UINavigationController
进行子类化,并覆盖其GetAnimationControllerForOperation()
委托方法,如下所示:
/// <summary>
/// Navigation controller subclass for assigning custom delegate.
/// </summary>
public partial class NavigationController : UINavigationController
{
/// <summary>
/// Initializes a new instance of the <see cref="T:Plimes.NavigationController"/> class.
/// </summary>
/// <param name="handle">Handle.</param>
public NavigationController (IntPtr handle) : base (handle)
{
Delegate = new NavigationControllerDelegate();
}
}
/// <summary>
/// Navigation controller delegate for custom transition animations.
/// </summary>
public class NavigationControllerDelegate : UINavigationControllerDelegate
{
/// <summary>
/// Gets the animation controller for operation.
/// </summary>
/// <returns>The animation controller for operation.</returns>
/// <param name="navigationController">Navigation controller.</param>
/// <param name="operation">Operation.</param>
/// <param name="fromViewController">From view controller.</param>
/// <param name="toViewController">To view controller.</param>
public override IUIViewControllerAnimatedTransitioning GetAnimationControllerForOperation(UINavigationController navigationController, UINavigationControllerOperation operation, UIViewController fromViewController, UIViewController toViewController)
{
// If left-right transition is needed
if (operation == UINavigationControllerOperation.Push)
{
var animator = new CircleFadeTransitionAnimator();
animator.IsPresentation = true;
return animator;
}
}
}
//
///用于分配自定义委托的导航控制器子类。
///
公共部分类NavigationController:UINavigationController
{
///
///初始化类的新实例。
///
///处理。
公共导航控制器(IntPtr句柄):基本(句柄)
{
委托=新的NavigationControllerDelegate();
}
}
///
///用于自定义过渡动画的导航控制器委托。
///
公共类NavigationControllerDelegate:UINavigationControllerDelegate
{
///
///获取用于操作的动画控制器。
///
///用于操作的动画控制器。
///导航控制器。
///手术。
///从视图控制器。
///查看控制器。
公共重写IUIViewController或初始化转换GetAnimationController以进行操作(UINavigationController导航控制器、UINavigationController操作、UIViewController从ViewController、UIViewController到ViewController)
{
//如果需要左右转换
if(操作==UINavigationControllerOperation.Push)
{
var animator=新的CircleFadeTransitionAnimator();
animator.IsPresentation=true;
返回动画师;
}
}
}
希望这会有帮助 “由内而外的展示”?你得解释一下你在说什么。你看过我的答案吗?它应该能解决你的问题!
/// <summary>
/// Circle animation delegate.
/// </summary>
class CircleAnimationDelegate : CAAnimationDelegate
{
IUIViewControllerContextTransitioning transitionContext;
//UIView toView;
/// <summary>
/// Initializes a new instance of the <see cref="T:Plimes.CircleAnimationDelegate"/> class.
/// </summary>
/// <param name="transitionContext">Transition context.</param>
public CircleAnimationDelegate(IUIViewControllerContextTransitioning transitionContext)
{
this.transitionContext = transitionContext;
//this.toView = toView;
}
/// <summary>
/// On Animations stopped.
/// </summary>
/// <param name="anim">Animation.</param>
/// <param name="finished">If set to <c>true</c> finished.</param>
public override void AnimationStopped(CAAnimation anim, bool finished)
{
transitionContext.CompleteTransition(!transitionContext.TransitionWasCancelled);
transitionContext.GetViewControllerForKey(UITransitionContext.ToViewControllerKey).View.Layer.Mask = null;
transitionContext.GetViewControllerForKey(UITransitionContext.FromViewControllerKey).View.Layer.Mask = null;
//toView.RemoveFromSuperview();
}
}
/// <summary>
/// Navigation controller subclass for assigning custom delegate.
/// </summary>
public partial class NavigationController : UINavigationController
{
/// <summary>
/// Initializes a new instance of the <see cref="T:Plimes.NavigationController"/> class.
/// </summary>
/// <param name="handle">Handle.</param>
public NavigationController (IntPtr handle) : base (handle)
{
Delegate = new NavigationControllerDelegate();
}
}
/// <summary>
/// Navigation controller delegate for custom transition animations.
/// </summary>
public class NavigationControllerDelegate : UINavigationControllerDelegate
{
/// <summary>
/// Gets the animation controller for operation.
/// </summary>
/// <returns>The animation controller for operation.</returns>
/// <param name="navigationController">Navigation controller.</param>
/// <param name="operation">Operation.</param>
/// <param name="fromViewController">From view controller.</param>
/// <param name="toViewController">To view controller.</param>
public override IUIViewControllerAnimatedTransitioning GetAnimationControllerForOperation(UINavigationController navigationController, UINavigationControllerOperation operation, UIViewController fromViewController, UIViewController toViewController)
{
// If left-right transition is needed
if (operation == UINavigationControllerOperation.Push)
{
var animator = new CircleFadeTransitionAnimator();
animator.IsPresentation = true;
return animator;
}
}
}