Back to Animated Tab Bar

RAMAnimatedTabBarController

docs/docsets/RAMAnimatedTabBarDemo.docset/Contents/Resources/Documents/index.html

5.2.03.9 KB
Original Source

RAMAnimatedTabBarController

RAMAnimatedTabBarController is a Swift module for adding animation to tabbar items. It has pre-set of animations which we prepare for you, and ability to use any custom animation you want. With this module you can make your tabbar alive like our shot on dribbble:

The iPhone mockup available here.

Screencast from our Demo

Requirements

  • iOS 7.0+
  • Xcode 6.1

Installation

Just add the RAMAnimatedTabBarController folder to your project.

or use CocoaPods with Podfile: ruby pod 'RAMAnimatedTabBarController'

or Carthage users can simply add to their Cartfile: github "Ramotion/animated-tab-bar"

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 :

Included Animations

  • RAMBounceAnimation
  • RAMLeftRotationAnimation
  • RAMRightRotationAnimation
  • RAMFlipLeftTransitionItemAnimations
  • RAMFlipRightTransitionItemAnimations
  • RAMFlipTopTransitionItemAnimations
  • RAMFlipBottomTransitionItemAnimations
  • RAMFrameItemAnimation
  • RAMFumeAnimation

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, textLable : UILabel) {
      // add animation
    }
// method call when Tab Bar Item is deselected
    override func deselectAnimation(icon : UIImageView, textLable : UILabel, defaultTextColor : UIColor) {
      // add animation
    }
// method call when TabBarController did load
    override func selectedState(icon : UIImageView, textLable : UILabel) {
      // set selected state  
    }
  1. Example:
class RAMBounceAnimation : RAMItemAnimation {

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

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

    override func selectedState(icon : UIImageView, textLable : UILabel) {
        textLable.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 = NSTimeInterval(duration)
        bounceAnimation.calculationMode = kCAAnimationCubic

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

About

The project maintained by app development agency Ramotion Inc. See our other open-source projects or hire us to design, develop, and grow your product.

© 2016 AlexKalinkin. All rights reserved. (Last updated: 2016-06-10)

Generated by jazzy ♪♫ v0.5.0, a Realm project.