[英]IOS Tab Bar Sliding
I'm trying to make tab bar with sliding (or may be swipe is right word?) effect of changing ViewControllers. 我正在尝试通过更改ViewControllers的滑动(或可能是正确的字眼?)效果来制作选项卡栏。
I create two ViewControllers with TableView on whole screen, but with restrictions - top edge of table not overlap top layout guide. 我在整个屏幕上使用TableView创建了两个ViewController,但是有一些限制-表格的顶部边缘与顶部布局指南不重叠。
I link this ViewControllers with TabBarController and when I use default animation - it's OK, work fine. 我将这个ViewControllers与TabBarController链接起来,当我使用默认动画时-可以,可以正常工作。 But I want sliding animation and do something like (swift3):
但是我想要滑动动画并执行类似(swift3)的操作:
func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool {
animateSliding(fromController: selectedViewController, toController: viewController)
return true
}
func animateSliding(fromController: UIViewController?, toController: UIViewController?) {
let fromView: UIView = fromController!.view;
let toView: UIView = toController!.view;
fromView.superview?.addSubview(toView);
toView.frame.origin.x = UIScreen.main.bounds.size.width;
UIView.animate(withDuration: 0.3,
animations: {
toView.frame.origin.x = 0;
fromView.frame.origin.x -= UIScreen.main.bounds.size.width;
},
completion: nil);
}
(it's not complete animation, just sample) (这不是完整的动画,仅是示例)
Now I have animation I wanted but second's ViewController's table overlap top guide when appear (when slide over first viewController). 现在我有想要的动画,但是第二个的ViewController的表在出现时(当滑过第一个viewController时)重叠了顶部向导。 If I change position ViewControllers in TabBar (first became second and second became first) situation change - not first controller's table overlap top guide (when appear)
如果我更改了TabBar中的ViewControllers位置(第一个变成第二个,第二个变成第一个),则情况发生了变化-不是第一个控制器的表与顶部指南重叠(出现时)
Have you tried XLPagerTabStrip ? 您是否尝试过XLPagerTabStrip ? I believe that it is pretty similar to what you want to achive.
我相信这与您要达到的目标非常相似。
If not, you can base your code in that implementation. 如果没有,您可以将代码基于该实现。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.