Minitour / AZTabBarController

A custom tab bar controller for iOS written in Swift 4.2
MIT License
348 stars 65 forks source link

Change tab bar icons on the fly #13

Closed ispiropoulos closed 7 years ago

ispiropoulos commented 7 years ago

Is there any way I could change one Icon on the fly without reinitializing the tab bar controller?

eg: tabController.setButtonImage(forIndex: Int, image: UIImage, highlightedImage: UIImage)

Minitour commented 7 years ago

@ispiropoulos There you go:

open func setButtonImage(forIndex index: Int, normal: UIImage,selected: UIImage){
        self.tabIcons?[index] = normal
        self.selectedTabIcons?[index] = selected
        updateInterfaceIfNeeded()
    }

Just put this function anywhere in the class and it should work.

ispiropoulos commented 7 years ago

Thank you, but this is what I get, probably due to the fact that the images are not monochrome but for example a profile picture. The last tab icon

screen shot 2017-05-15 at 18 13 26

is the one that changed

Edit: I found the ignoreColor flag :) That's ok now :) Thank you