[英]MvvmCross v5 animation between two root presentations
I have two iOS views marked by MvxRootPresentation
attribute: LoginView
without wrapping into navigation controller and MainView
with wrapping into navigation controller. 我有两个标记为
MvxRootPresentation
属性的iOS视图: LoginView
没有包装到导航控制器中,而MainView
包含在导航控制器中。
When I call ShowViewModel<MainViewModel>()
there is no animation between these two views. 当我调用
ShowViewModel<MainViewModel>()
,这两个视图之间没有动画。 All subsequent views are animated as usual (within NavigationController). 所有后续视图都像往常一样动画(在NavigationController中)。
How can I set animation for this transition? 如何为此过渡设置动画?
Ok, I've did it myself :) I had to add my custom presentation attribute and custom presenter: 好的,我自己做了:)我必须添加我的自定义演示文稿属性和自定义演示者:
public class AnimatedRootPresentationAttribute : MvxRootPresentationAttribute
{
}
public class MyPresenter : MvxIosViewPresenter
{
public MyPresenter(IUIApplicationDelegate appDelegate, UIWindow window)
: base(appDelegate, window)
{
}
protected override void RegisterAttributeTypes()
{
base.RegisterAttributeTypes();
_attributeTypesToShowMethodDictionary.Add(typeof(AnimatedRootPresentationAttribute),
(viewController, attribute, request) => ShowAnimatedRootViewController(
viewController, (AnimatedRootPresentationAttribute)attribute, request));
}
private void ShowAnimatedRootViewController(
UIViewController viewController,
AnimatedRootPresentationAttribute attribute,
MvxViewModelRequest request)
{
ShowRootViewController(viewController, attribute, request);
AddAnimation();
}
private void AddAnimation()
{
var transition = new CATransition
{
Duration = 0.2,
Type = CAAnimation.TransitionMoveIn,
Subtype = CAAnimation.TransitionFromTop
};
_window.RootViewController.View.Layer.AddAnimation(transition, null);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.