i am trying to animate my navigationItem.rightBarButtonItem
to blink repeatedly from green to white... So I do this
UIView.animateWithDuration(1.0, delay:0, options: [.Repeat, .Autoreverse], animations: {
self.navigationItem.rightBarButtonItem?.tintColor = .greenColor()
}, completion: nil)
as i see in this question
and it work
the problem is that i am using UITabView
and every time i switch between views and return to the first view the blink is stop
and i think its because i stuck layer after layer of animation somewhere
i understand that to remove the animation i should use layer.removeAllAnimations()
the problem is that i don't know which view to do it on
i tried self.view.layer.removeAllAnimations()
and it didn't work.
how do i get to this layer that i create for the navigationItem animation
so i can remove it?
i solve this issue with relocating the creation of the animation
in the beginning i placed that in the viewWillAppear function
and also tried to init the button to white color just before that
but its looks like it didn't work that way so i relocate the animation to
the viewDidAppear function and leave the init of the button to white color
in the viewWillAppear and its seems to work ok now :)
thanks