Ramotion / animated-tab-bar

:octocat: RAMAnimatedTabBarController is a Swift UI module library for adding animation to iOS tabbar items and icons. iOS library made by @Ramotion
https://www.ramotion.com/animated-tab-bar-ios-app-development-ui-library/
MIT License
11.12k stars 1.33k forks source link

Setting image and title via nib not storyboard #282

Closed renchris closed 4 years ago

renchris commented 4 years ago

Hello,

I'm trying to set my Tab Item image, selectedImage, and title from within my Swift file, rather than inputing them from the dropdown options in the Storyboard. However, it seems that the images and title set in the Storyboard are still shown over the images and title set in my Swift file, so both are showing. I am wanting and expecting any attributes assigned or modified in my Swift file to override it but it is not. I have tried following the readme, previous issues, Apple documentation, and tracing the implementation, but I am still stuck.

I have attached a screenshot of my code and simulator. You can see that the title "WHATS UP" and icon "person" from my Swift file is shown but they're under the still showing title "First" from the storyboard. The icon was initially and visibly the "square" from the Storyboard, but I clicked the "Second" tab so the icon changed to "pencil" due from my Custom Animation which I implemented hoping it would fix the issue but doesn't. The "First" text is red because of animatedItems[0].textColor = UIColor.red, but I expected it to change the "WHATSUP" text.

So, I am wanting to chose and display the title and images from the Swift file but the title and images are still showing from Storyboard. Would I be able to get help with this?

Thanks!

Screen Shot 2020-04-20 at 1 30 47 AM

renchris commented 4 years ago

I fixed my issue by my lines of code that modify the RAMAnimatedTabBarItem attributes in animatedItems to be before the super.viewDidLoad()

I also used my custom animation class to correctly colour the icon.image or icon.highlightedImage and setting icon.isHighlighted to false or true respectively for a selected or unselected item in the playAnimation, deselectAnimation, and selectedState functions.