NMAnimatedTabBarItem
NMAnimatedTabBarItem 是一个基于 Swift 的 UI 模块库,用于向 iOS 标签栏项和图标添加动画。由 @Namshi Mobile Team 开发的 iOS 库。
要求
- iOS 9.0+
- xCode 9
- Swift 3.2
安装
只需将 NMAnimatedTabBarItem 文件夹添加到您的项目中。或者,使用带有 Podfile 的 CocoaPods。
pod 'NMAnimatedTabBarItem'
使用说明
- 导入 NMAnimateTabBarItem 框架。
import NMAnimatedTabBarItem
- 创建一个类型为 NMAnimateTabBarItem 的实例。
var animatedTabBar = NMAnimateTabBarItem()
- 将 UITabBarControllerDelegate 集合到您的类中。
class ViewController: UITabBarController , UITabBarControllerDelegate {
//do Your stuff
}
- 实现 UITabBarControllerDelegate 方法。
func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool {
return true
}
- 找到所选选项卡的索引并调用 animateTabBarItem。
let indexOfTab = tabBarController.viewControllers?.index(of:viewController)
animatedTabBar.animateTabBarItem(self.tabBar, indexOfTab!, 2 , NMAnimationtype.Bounce)
- 确保增加了 UITabBar 项的图像。
包含的动画
- 弹性动画
- 旋转
- 过渡
- 帧
自定义属性
- 更改动画时长。
animatedTabBar.duration = 0.2
- 提供过渡选项。
animatedTabBar.transitionOptions = UIViewAnimationOptions.transitionFlipFromBottom
- 更改旋转方向
animatedTabBar.direction = NMRotationDirection.right
- 传递帧动画的图片名称
animationType = NMAnimationtype.Frame
var imagesArray :[String] = []
for index in 0...35 {
imagesArray.append("frame_\(index)")
}
animatedTabBar.createImagesArray(imagesArray)
- 传递帧动画的图片
animationType = NMAnimationtype.Frame
imagesList.append((UIImage(named: "image.png")?.cgImage)!)
imagesList.append((UIImage(named: "image2.png")?.cgImage)!)
imagesList.append((UIImage(named: "image3.png")?.cgImage)!)
animatedTabBar.animationImages = imagesList
手册
您可以从我们的发布页面下载最新文件。完成后,将源文件夹中的Swift文件复制到您的项目中。
示例
查看示例项目。
版权
此库受RAMAnimatedTabBarController的启发而创建。
版权所有,Namshi团队2018年。