一款靈動的動畫標簽欄類庫:Ramotion/animated-tab-bar

jopen 10年前發布 | 27K 次閱讀 Apple Swift開發 Ramotion/animated-tab-bar

一款靈動的動畫標簽欄類庫。可在storyboard中直接使用,非常方便。Demo效果非常漂亮。遞交僅一周時間,今天即在GitHub上以122顆星極速躍居到Swift分類第一的位置。tab-bar-icons-iphone-ramotion-animation-interface-design.gif

要求

  • iOS 7.0+
  • Xcode 6.1
  • </ul>

    安裝

    Just add the RAMAnimatedTabBarController folder to your project.

    用法

    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_CLASSDemonstration video for step 5

    包含的動畫

    • RAMBounceAnimation
    • RAMLeftRotationAnimation
    • RAMRightRotationAnimation
    • RAMFlipLeftTransitionItemAniamtions
    • RAMFlipRightTransitionItemAniamtions
    • RAMFlipTopTransitionItemAniamtions
    • RAMFlipBottomTransitionItemAniamtions
    • RAMFrameItemAnimation

    創建自定義動畫

    1. Create a new class which inherits from RAMItemAnimation:

         class NewAnimation : RAMItemAnimation
    2. 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  
        }
    3. 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")
        }
    }

    項目主頁:http://www.baiduhome.net/lib/view/home/1417099279518

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!