🌟 特点
- 零配置
- 不同的动画
- 轻松启用/禁用交互
- 流畅的手势
📲 安装
CocoaPods
使用编辑您的 Podfile
并指定依赖项
pod 'SwipeableTabBarController'
Carthage
使用编辑您的 Cartfile
并指定依赖项
github "marcosgriselli/SwipeableTabBarController"
手动
将 SwipeableTabBarController/Classes 中的类文件拖入您的项目中。
👩💻 如何使用
设置
如果不需要继承 UITabBarController
,只需将 Storyboard 上的 UITabBarController
设置为 SwipeableTabBarController
类型即可。
否则,创建 SwipeableTabBarController
的子类。
import SwipeableTabBarController
class TabBarController: SwipeableTabBarController {
// Do all your subclassing as a regular UITabBarController.
}
动画
SwipeableTabBarController
默认支持3种不同类型的动画。设置所需的动画非常简单。在你的 SwipeableTabBarController
子类中只需这样做
swipeAnimatedTransitioning?.animationType = SwipeAnimationType.sideBySide
如果你只支持一种动画类型,可以在 viewDidLoad()
中调用它,否则按需调用以更改所需的动画。
并排显示(默认)
默认动画是 SwipeAnimationType.sideBySide
,在此动画中,新选中的标签将以前一个相同速度进入屏幕。
重叠
SwipeAnimationType.overlap
新选中的标签将进入并占据中央位置,而上一个标签保持其位置。
推送
SwipeAnimationType.push
按照iOS默认的推送动画,顶部视图移开,而底部视图则微向后移动。在这种情况下,顶部视图将是之前选中的标签视图。
启用循环播放
SwipeableTabBarController
支持像旋转木马一样在第一个和最后一个标签之间循环播放。只需将 isCyclingEnabled
设置为 true
即可。
默认值为 false
isCyclingEnabled = true
触摸次数的最小/最大值
您可以设置处理 Swipe 手势所需的最小和最大触摸次数。只需设置 minimumNumberOfTouches
或 maximumNumberOfTouches
属性。
默认值为 1
minimumNumberOfTouches = 2
默认值为 Int.max
maximumNumberOfTouches = 2
禁用交互
支持启用/禁用交互者,这可以用于使用水平滚动视图或地图(在示例中)的控制器。
默认值为 true
isSwipeEnabled = false
❤️ 贡献
这是一个开源项目,所以请随意贡献。如何做?
贡献者
👨💻 作者
Marcos Griselli | @marcosgriselli
🛡 许可证
MIT License
Copyright (c) 2018 Marcos Griselli
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.