[英]MvvmCross v5 animation between two root presentations
我有两个标记为MvxRootPresentation
属性的iOS视图: LoginView
没有包装到导航控制器中,而MainView
包含在导航控制器中。
当我调用ShowViewModel<MainViewModel>()
,这两个视图之间没有动画。 所有后续视图都像往常一样动画(在NavigationController中)。
如何为此过渡设置动画?
好的,我自己做了:)我必须添加我的自定义演示文稿属性和自定义演示者:
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.