303

GitHub - Ramotion/animated-tab-bar: RAMAnimatedTabBarController is a Swift UI mo...

 6 years ago
source link: https://github.com/Ramotion/animated-tab-bar
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

README.md

header Animation

Animated-tab-bar

CocoaPods CocoaPods Carthage compatible Swift 4.0 Twitter Travis Donate

About

This project is maintained by Ramotion, Inc.
We specialize in the designing and coding of custom UI for Mobile Apps and Websites.

Looking for developers for your project?
This project is maintained by Ramotion, Inc. We specialize in the designing and coding of custom UI for Mobile Apps and Websites.

contact_our_team@2x.png

The iPhone mockup available here.

Try this UI control in action

Download_on_the_App_Store_Badge_US-UK_135x40.png

Screencast from our Demo

Animation

Requirements

  • iOS 9.0+
  • xCode 9

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"

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

  • 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, 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")
    }
}

Get the Showroom App for iOS to give it a try

Try this UI library in our iOS app. Contact us if you interested in hiring the team.

app_store@2x.png contact_our_team@2x.png

Follow us for the latest updates
68747470733a2f2f692e696d6775722e636f6d2f7a69537165536f2e706e672f


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK