我有两个标有osgi:install -s mvn:com.tuts.abhinav/rest-service/1.0-SNAPSHOT
属性的iOS视图:MvxRootPresentation
没有包装到导航控制器中,而LoginView
包含在导航控制器中。
当我调用MainView
时,这两个视图之间没有动画。所有后续视图都像往常一样动画(在NavigationController中)。
如何为此过渡设置动画?
答案 0 :(得分:6)
好的,我自己做过:)我必须添加自定义演示文稿属性和自定义演示者:
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);
}
}