MMDrawerController 使用 Swift 预建动画

Posted

技术标签:

【中文标题】MMDrawerController 使用 Swift 预建动画【英文标题】:MMDrawerController Pre Built Animations with Swift 【发布时间】:2015-06-26 20:08:12 【问题描述】:

我正在使用MMDrawerController,我正在尝试改变抽屉滑出的方式。

在目标 C 中,我会这样做

[drawerController setDrawerVisualStateBlock:[MMDrawerVisualState slideAndScaleVisualStateBlock]]

更改抽屉滑出到Slide and Scale 动画的方式。

然而,在 Swift 中,我似乎无法做到这一点。这就是我使用 swift 的地方:

drawerController.setDrawerVisualStateBlock  (MMDrawerController!, MMDrawerSide, CGFloat) -> Void in

        

我无法在块内调用类似 MMRawerVisualState.slideAndScaleVisualStateBlock() 的东西。 Swift 不支持此功能吗?

【问题讨论】:

【参考方案1】:

在 Objective-c 中,你传递了一个类方法,它返回一个动画块(MMDrawerControllerDrawerVisualStateBlock 的类型)。但是你没有在 swift 版本的代码中传递相同的方法(你正在实现它)。

drawerController.setDrawerVisualStateBlock(MMDrawerVisualState.slideAndScaleVisualStateBlock)

【讨论】:

这实际上是我必须使用的代码:drawerController.setDrawerVisualStateBlock(MMDrawerVisualState.slideAndScaleVisualStateBlock()!) Cheers! 你们俩,你的回答太棒了。谢谢。

以上是关于MMDrawerController 使用 Swift 预建动画的主要内容,如果未能解决你的问题,请参考以下文章

关于iOS抽屉MMDrawerController手势冲突

带有 StoryBoard 菜单项的 MMDrawerController

中心控制器具有滚动视图时的 MMDrawerController 平移手势行为

iOS分组通讯录效果+側滑菜单(MMDrawerController)

抽屉框架的用法(转)

什么是恢复标识符?