animated-tab-bar README

The project's README from github.com/Ramotion/animated-tab-bar. As one markdown file: README.md.

ANIMATED TAB BAR

Swift UI module library for adding animation to iOS tabbar items and icons.


We specialize in the designing and coding of custom UI for Mobile Apps and Websites.

Stay tuned for the latest updates:


CocoaPods CocoaPods Carthage compatible Swift 4.0 Twitter Travis Donate

Requirements

Installation

Just add the RAMAnimatedTabBarController folder to your project.

or use CocoaPods with Podfile:

pod 'RAMAnimatedTabBarController'

or Carthage users can simply add to their Cartfile:

github "Ramotion/animated-tab-bar"

or Swift Package Manager

Usage

  1. Create a new UITabBarController in your storyboard or nib.

  2. Set the class of the UITabBarController to RAMAnimatedTabBarController in your Storyboard or nib.

  3. For each UITabBarItem, set the class to RAMAnimatedTabBarItem.

  4. Add a custom image icon for each RAMAnimatedTabBarItem

  5. Add animation for each RAMAnimatedTabBarItem :

    • drag and drop an NSObject item into your ViewController
    • set its class to ANIMATION_CLASS (where ANIMATION_CLASS is the class name of the animation you want to use)
    • connect the outlet animation in RAMAnimatedTabBarItem to your ANIMATION_CLASS Demonstration video for step 5

Included Animations

Creating Custom Animations

  1. Create a new class which inherits from RAMItemAnimation:
   class NewAnimation : RAMItemAnimation
  1. Implement the methods in RAMItemAnimationProtocol:
  // method call when Tab Bar Item is selected
  override func playAnimation(icon: UIImageView, textLabel: UILabel) {
    // add animation
  }
  // method call when Tab Bar Item is deselected
  override func deselectAnimation(icon: UIImageView, textLabel: UILabel, defaultTextColor: UIColor, defaultIconColor: UIColor) {
    // add animation
  }
  // method call when TabBarController did load
  override func selectedState(icon: UIImageView, textLabel: UILabel) {
    // set selected state  
  }
  1. Example:
import RAMAnimatedTabBarController

class RAMBounceAnimation : RAMItemAnimation {

    override func playAnimation(_ icon: UIImageView, textLabel: UILabel) {
        playBounceAnimation(icon)
        textLabel.textColor = textSelectedColor
    }

    override func deselectAnimation(_ icon: UIImageView, textLabel: UILabel, defaultTextColor: UIColor, defaultIconColor: UIColor) {
        textLabel.textColor = defaultTextColor
    }

    override func selectedState(_ icon: UIImageView, textLabel: UILabel) {
        textLabel.textColor = textSelectedColor
    }

    func playBounceAnimation(_ icon : UIImageView) {

        let bounceAnimation = CAKeyframeAnimation(keyPath: "transform.scale")
        bounceAnimation.values = [1.0 ,1.4, 0.9, 1.15, 0.95, 1.02, 1.0]
        bounceAnimation.duration = TimeInterval(duration)
        bounceAnimation.calculationMode = kCAAnimationCubic

        icon.layer.add(bounceAnimation, forKey: "bounceAnimation")
    }
}

📄 License

Animated Tab Bar is released under the MIT license. See LICENSE for details.

This library is a part of a selection of our best UI open-source projects.

If you use the open-source library in your project, please make sure to credit and backlink to www.ramotion.com

📱 Get the Showroom App for iOS to give it a try

Try this UI component and more like this in our iOS app. Contact us if interested.



animated-tab-bar (Ramotion/animated-tab-bar)

Searching Database…

这是什么?RAMAnimatedTabBarController 是一个 Swift UI 模块库,可为 iOS 标签栏项目和图标添加动画效果。
这是独立的应用,还是需要添加到我项目中的库?它是一个可以直接放入现有 iOS 项目中的库,提供一个自定义的 UITabBarController 子类,而不是独立应用。
如何将它添加到我的项目中?直接添加 RAMAnimatedTabBarController 文件夹,或通过 CocoaPods、Carthage 或 Swift Package Manager 安装。
使用它之前我需要准备什么?你需要 Xcode 10.2,以及一个面向 iOS 9.0 或更高版本的项目。
如何在 Storyboard 中进行设置?将 UITabBarController 的类设置为 RAMAnimatedTabBarController,将每个 UITabBarItem 的类设置为 RAMAnimatedTabBarItem,添加自定义图标,然后将一个 NSObject 拖入视图控制器,设置为所选的动画类,并连接为 Outlet。
它能用于 iOS 以外的平台吗,比如 macOS 应用?不能,它是专为 iOS 标签栏(UIKit)打造的,并不是跨平台的 UI 库。
内置了哪些动画?内置九种预设的标签项动画,例如 RAMBounceAnimation、RAMLeftRotationAnimation、RAMRightRotationAnimation、翻转方向过渡(左/右/上/下)、RAMFrameItemAnimation 和 RAMFumeAnimation。
我能制作自己的自定义动画吗?可以,你需要创建一个继承自 RAMItemAnimation 的类,并实现 RAMItemAnimationProtocol 中定义的方法。
Creator
Ramotion
Size
9.4 MB
Stars
11.1K
Age
11y
Commits · 90 Days