我有一个带有自定义转换的自定义Recyclerview
(即android:layout_below="@id/recyclerview"
)。我决定用UITabBarController
进行互动。问题?无论我在UIViewControllerAnimatedTransitioning
子句中尝试什么,交互性要么停止工作,要么(如下面的代码中所示)手势识别器仅在水平方向上工作(我需要这个,但它知道怎么做?)但是只在左到右的方向(我需要相反)。有帮助吗?
以下是重要的自定义标签栏控制器类的代码:
UIPercentDrivenInteractiveTransition
这是我的.began
课程:
class FloatingTabBarViewController: UITabBarController {
private let screenSize: CGRect = UIScreen.main.bounds
var interactor = FloatingTabBarPercentDrivenInteraction()
var floatingView = FloatingTabBarView()
override func viewDidLoad() {
super.viewDidLoad()
self.delegate = self
self.tabBar.isHidden = true
self.selectedIndex = 0
self.addTabBarIcons()
floatingView = FloatingTabBarView(frame: CGRect(x: 0, y: screenSize.height - 54 - 36, width: screenSize.width*0.274666666, height: 54))
floatingView.center.x = self.tabBar.center.x
floatingView.datasource = self
floatingView.delegate = self
floatingView.setup()
interactor.wireToViewController(viewController: self)
self.view.addSubview(floatingView)
}
}
extension FloatingTabBarViewController: UITabBarControllerDelegate {
func tabBarController(_ tabBarController: UITabBarController, animationControllerForTransitionFrom fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
return FloatingTabBarAnimatedTransitioning()
}
func tabBarController(_ tabBarController: UITabBarController, interactionControllerFor animationController: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning? {
return interactor.interactionInProgress ? interactor : nil
}
}