我正在使用MMDrawerController在我的ios应用程序中创建侧边栏,我已经成功实现了它,但是我正在尝试在侧边栏显示时减少中心视图的alpha值,正如您通常在大多数具有类似功能的应用程序上看到的那样,但是我收到了错误
Type of expression is ambiguius without more context
以下是我的AppDelegate中的代码,visualstateblock部分正在抛出错误
func buildNavigationDrawer()
{
// Instantiate Main.storyboard
let mainStoryBoard:UIStoryboard = UIStoryboard(name:"Main", bundle:nil)
// Create View Controllers
let mainPage:TabBarViewController = mainStoryBoard.instantiateViewController(withIdentifier: "TabBarViewController") as! TabBarViewController
let rightSideMenu:HomeSideMenuViewController = mainStoryBoard.instantiateViewController(withIdentifier: "HomeSideMenuViewController") as! HomeSideMenuViewController
// Wrap into Navigation controllers
let rightSideMenuNav = UINavigationController(rootViewController:rightSideMenu)
// Cerate MMDrawerController
drawerContainer = MMDrawerController(center: mainPage, rightDrawerViewController: rightSideMenuNav)
//drawerContainer!.openDrawerGestureModeMask = MMOpenDrawerGestureMode.PanningCenterView
drawerContainer!.closeDrawerGestureModeMask = MMCloseDrawerGestureMode.panningCenterView
drawerContainer!.setDrawerVisualStateBlock { (drawerContainer, rightSideMenuNav) in
drawerContainer!.centerViewController.view.alpha = 0.3;
}
// Assign MMDrawerController to our window's root ViewController
window?.rootViewController = drawerContainer
}
感谢您的帮助
答案 0 :(得分:1)
在setDrawerVisualStateBlock
中,返回的MMDrawerController
不是可选的,但背后仍有强制包装!
这告诉编译器从前一行(你创建的那一行)获取可选值
要解决此问题,请更改其中一个变量名称或使用此项:
drawerContainer?.setDrawerVisualStateBlock { $0.0.centerViewController.view.alpha = 0.3 }