GithubHelp home page GithubHelp logo

ramotion / animated-tab-bar Goto Github PK

View Code? Open in Web Editor NEW
11.1K 318.0 1.3K 9.44 MB

:octocat: RAMAnimatedTabBarController is a Swift UI module library for adding animation to iOS tabbar items and icons. iOS library made by @Ramotion

Home Page: https://www.ramotion.com/animated-tab-bar-ios-app-development-ui-library/

License: MIT License

Ruby 0.90% Swift 98.31% Objective-C 0.79%
swift ios library ui animation material-design

animated-tab-bar's Introduction

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

  • iOS 9.0+
  • Xcode 10.2

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

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

📄 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's People

Contributors

0ber avatar aleksei1000000 avatar alexmik89 avatar alostsega avatar devladinci avatar dkloeck-adi avatar douvi avatar efremidze avatar fuzz6001 avatar igork-ramotion avatar ikolpachkov avatar jameson-reed avatar juriv avatar khoren93 avatar kirankunigiri avatar kirualex avatar liberty4me avatar mn288 avatar naoyashiga avatar okipol88 avatar polobymulberry avatar ramotiondev avatar ramotionrussell avatar ronnielsen avatar soriur avatar strivingboy avatar tfrank64 avatar thinkclay avatar xbeg9 avatar younatics avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

animated-tab-bar's Issues

setImageInsets tabBarItem

I tried to change insets of every tabbaritems both programmatically and using storyboard. It doesn't work.
ios simulator screen shot feb 4 2015 2 42 07 pm

Code that I tried:
self.tabBarItem.imageInsets=UIEdgeInsetsMake(5, 0, -5, 0);
and also
for (RAMAnimatedTabBarItem *item in self.tabBarController.tabBar.items) {
item.imageInsets=UIEdgeInsetsMake(5, 0, -5, 0);
}

Thanks!

EXC_BAD_INSTRUCTION when using programatically

Hey guys,

I'm not using storyboard or any nib files to build up my view - just doing it manually. To give you a short overview:

I've a custom class which inherits from RAMAnimatedTabBarController. In the viewDidLoad of my custom class I call super.viewDidLoad which calls the one of RAMAnimatedTabBarController.

Then I got the described error in line:157:

func createViewContainers() -> NSDictionary {
    // ...
    let itemsCount : Int = tabBar.items!.count as Int - 1
    // ...
}

tabBar.items is by default nil, at least the public api says it:

var items: [AnyObject]? // get/set visible UITabBarItems. default is nil. changes not animated. shown in order

So I guess here is the problem. Would be nice if you can give a hint on how to implement your controller manually. I followed the steps you show up and exchanged all UITabBar* classes with the ones you declared and set the animation but as said it crashes on the viewDidLoad of the RAMAnimatedTabBarController.

Raised middle tab icon

Have you included a custom class for the raised middle tab bar icon included in your first mockup GIF?

UITabbarItem hidden issue

When I pushed from a VC to anothor VC,I want to hide the tabbar. So what I do first is set the "Hide Bottom Bar on Push" in the Storyboard ,the result is the tabbar is hidden indeed but the UITabbarItems are still.I also use UIVIew.animateWIthDurarion() to hide the tabbar but also failed.What can I do to hide the tabbar and the tabbaritem?

Cannot set tintColor

I have tried setting the tintColor via UITabBar.appearance().tintColor = UIColor.greenColor() or even in the Interface Builder and to no avail. It doesn't seem to work

About the hidden problems

I set hidesBottomBarWhenPushed is YES.It's display like this.I want to hide it, can you tell me what should I do?
ios simulator screen shot 2015 1 14 1 59 17

update to Swift 2.0

Hi, I'm getting errors in Xcode 7. Do you have plans to update to Swift 2.0?

Thanks

No shared scheme for Carthage

I'd like to include this project in my cartfile but the RAMAnimatedTabBarDemo project file doesn't contain a shared xcode scheme thus carthage update fails. An embedded framework wouldn't be necessary that way iOS 7 can still be targeted. I'd submit a pull request but I'm not certain how the .gitignore should be updated to allow these changes to be included.

Urgently: How can I change the selectedIndex tab?

When I use tabBarController?.selectedIndex it doesn't change the color in the animated tab, and I have tried using setSelectIndex() function but it didn't work, I really like this library but I have a deadline. Thanks in advance.

Inspectable textColor is nil if set to default

If @IBInspectable var textColor: UIColor = UIColor.blackColor() set via IB to default, tint color of tab item will be blue (nil actually), not tab bar default tint. I think this should be fixed.
If you want, I can create PR with this fix.

Errors in Project-swift.h

Having issues compiling in Xcode 7 beta 6 (Swift 2.0).

Getting a compile error:

Type argument 'CGImageRef' (aka 'struct CGImage *') is neither an Objective-C object nor a block type

Please see the attached screen. This is in the autogenerated "Project-swift.h" file.

Any ideas how to fix this? Kinda stuck here.

Thanks!

ram_swift_errors

Delegate methods not being called

I have a subclass of RAMAnimatedTabBarController that works fine except that func tabBarController(tabBarController: UITabBarController, didSelectViewController viewController: UIViewController) is never called.

If my class is

class MasterTabBarViewController: RAMAnimatedTabBarController, UITabBarControllerDelegate

then that delegate method is never called.

But if I change it to

class MasterTabBarViewController: UITabBarController, UITabBarControllerDelegate

then it works as expected.

How can I get RAMAnimatedTabBarController to pass along the delegate method calls?

Badge position

I tried adding a badge to the RAMAnimatedTabBarItem and it is offset. Instead of sticking to the right it sticks to the left. Furthermore, it appears BEHIND the icon.

undefine key

reason: '[<UITabBarItem 0x170149e20> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key animation.'

I implement 5 points exactly as you mention also watch your video not sure where i am wrong.

Badge bug.

When I set the tabbar badge to nil twice in a row the badge appears just red circle without text (number) instead of disappearing.

I fixed it by update the method:

override var badgeValue: String? {
    get {
        return badge?.text
    }
    set(newValue) {

        if newValue == nil {
            badge?.removeFromSuperview()
            badge = nil;
            return
        }

        if badge == nil { // remove => && badge != nil
            badge = RAMBadge.bage()
            if let contanerView = self.iconView!.icon.superview {
                badge!.addBadgeOnView(contanerView)
            }
        }

        badge?.text = newValue
    }
}

Thanks

please update cocoapod

here is the code
wupengdeAir:iOS-ArtCircle wupeng$ gem source -l
*** CURRENT SOURCES ***

https://rubygems.org/
wupengdeAir:iOS-ArtCircle wupeng$ pod search RAMAnimatedTabBarController

-> RAMAnimatedTabBarController (1.0.1)
RAMAnimatedTabBarController is a Swift module for adding animation to tabbar
items.
pod 'RAMAnimatedTabBarController', '~> 1.0.1'

How to use it with Code?

i never use storyboard, i need use it in code,

i try it like this,bug it failed:

    let tabVC = AnimTabVC()

    let tabBar = UITabBar()
    let vc1 = UIViewController()
    vc1.title = "首页"
    let tabbarItem1 = RAMAnimatedTabBarItem()
    tabbarItem1.animation = RAMLeftRotationAnimation()
    tabbarItem1.title = "首页"
    tabbarItem1.image = UIImage(named: "main")
    vc1.tabBarItem = tabbarItem1

    let vc2 = UIViewController()
    let tabbarItem2 = RAMAnimatedTabBarItem()
    tabbarItem2.animation = RAMLeftRotationAnimation()
    tabbarItem2.title = "聊天"
    tabbarItem2.image = UIImage(named: "favorites")
    vc2.tabBarItem = tabbarItem2

    let vc3 = UIViewController()
    let tabbarItem3 = RAMAnimatedTabBarItem()
    tabbarItem3.animation = RAMLeftRotationAnimation()
    tabbarItem3.title = "我的"
    tabbarItem3.image = UIImage(named: "mine")
    vc3.tabBarItem = tabbarItem3
    tabVC.viewControllers = [vc1,vc2,vc3]
    tabBar.items = [tabbarItem1,tabbarItem2,tabbarItem3]

    tabVC.setValue(tabBar, forKey: "tabBar")





    tabVC.tabBar.tintColor = UIColor.redColor()

Build issues and crash in createViewContainers

Having several issues trying to get RAMAnimatedTabBarController working.

Steps:

  1. Created a new Swift project and downloaded the code from github (tried to install the pod, but was told that the RAMAnimatedTabBarControllerpod couldn't be found).
  2. Followed the instructions in the Main.storyboard that was created to get everything set up. When I tried to run the app I got the following:
2015-06-19 12:40:40.304 GoalsExperiment1[8598:154387] Unknown class RAMAnimatedTabBarItem in Interface Builder file.
2015-06-19 12:40:40.323 GoalsExperiment1[8598:154387] Unknown class RAMLeftRotationAnimation in Interface Builder file.
2015-06-19 12:40:40.324 GoalsExperiment1[8598:154387] Unknown class RAMAnimatedTabBarItem in Interface Builder file.
2015-06-19 12:40:40.324 GoalsExperiment1[8598:154387] Unknown class RAMBounceAnimation in Interface Builder file.
2015-06-19 12:40:40.324 GoalsExperiment1[8598:154387] Unknown class RAMAnimatedTabBarController in Interface Builder file.
2015-06-19 12:40:40.344 GoalsExperiment1[8598:154387] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UITabBarItem 0x7fc24ad45c70> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key animation.'

In order to fix this, I created a new Storyboard file and replicated the setup, however I am now getting another

ramanimatedtabbarcontroller_swift
crash.

It looks like viewDidLoad is being called twice. The first time, tabBar.items has a count of 2 for the 2 tabs that I created, the second time it is nil.

Any help would be appreciated.

Issue with icon color

Hi,
I'm having a little issue with the icon's color.
Before a tab bar is selected, its icon's color is wrong.

For example: my TextColor is dark grey, and my TextSelectedColor and IconSelectedColor are white.
Before I select a tab bar it appears with dark grey text (which is correct) and white icon (which is wrong).

screen shot 2015-06-15 at 9 33 11 am

Have I configured something wrong? Or is it a bug?
Thanks!

Root View Controller seemingly lost upon tab switch while Modal View is active

I noticed that if I switch tabs while a modal window is up and then return to the tab, the controller behind the modal turns into a complete black screen. I imagine this is not intended behavior?

I was able to implement a fix by closing the modal upon tab switch, which was fine for me, however it's not the most elegant fix as closing a modal upon moving away from it is not a behavior desired by everyone.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.