Skip to content

Commit

Permalink
Fix Observer Time
Browse files Browse the repository at this point in the history
  • Loading branch information
MillmanY committed Dec 20, 2016
1 parent 71d40e9 commit b4e5050
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
2 changes: 1 addition & 1 deletion MMTabBarAnimation.podspec
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'MMTabBarAnimation'
s.version = '0.2.8'
s.version = '0.2.9'
s.summary = 'Custom TabBar Animation'

# This description is used to generate tags and improve search results.
Expand Down
31 changes: 21 additions & 10 deletions MMTabBarAnimation/Classes/AnimateItem.swift
Expand Up @@ -24,34 +24,39 @@ public enum ItemAnimateType {
}

class MMAnimateItem: NSObject {

var label:UILabel?
var badgeAnimateType:AnimateType = .none
var animateType:ItemAnimateType = .content(type: .none)
var duration:TimeInterval = 0.3
var badge:UIView?

var imgAnimateLayer:ImageAnimateLayer = {
let layer = ImageAnimateLayer()
return layer
}()
var item:UITabBarItem?
var badge:UIView?

var item:UITabBarItem? {
didSet {
self.observerBadge()
}
}

var icon:UIImageView? {
didSet {
if let i = icon {
imgAnimateLayer.frame = i.bounds
}
}
}
var label:UILabel?
var badgeAnimateType:AnimateType = .none
var animateType:ItemAnimateType = .content(type: .none)

var tabBarView:UIView? {
didSet {
self.setItem()
}
}
var duration:TimeInterval = 0.3

fileprivate func setItem() {
if let barItem = self.item , barItem.observationInfo == nil{
barItem.addObserver(self, forKeyPath: "badgeValue", options: .new, context: nil)
}

if let contentImageClass = NSClassFromString("UITabBarSwappableImageView"),
let contentLabelClass = NSClassFromString("UITabBarButtonLabel") {

Expand All @@ -68,6 +73,12 @@ class MMAnimateItem: NSObject {
}
}

fileprivate func observerBadge() {
if let barItem = self.item , barItem.observationInfo == nil{
barItem.addObserver(self, forKeyPath: "badgeValue", options: .new, context: nil)
}
}

func animateBadge(type:AnimateType) {
var delay = 0.0
if badge == nil {
Expand Down

0 comments on commit b4e5050

Please sign in to comment.