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

Building an app using this tab bar without storyboard is a nightmare #150

Closed iwheelbuy closed 6 years ago

iwheelbuy commented 7 years ago
class MainView: RAMAnimatedTabBarController {

    convenience init() {
        let controllerEvents = UINavigationController(rootViewController: EventsView())
        controllerEvents.tabBarItem = EventsViewTabItem()
        let controllerPhotos = UINavigationController(rootViewController: PhotosView())
        controllerPhotos.tabBarItem = EventsViewTabItem()
        let viewControllers = [
            controllerEvents,
            controllerPhotos
        ]
        self.init(viewControllers: viewControllers)
    }
}

class EventsViewTabItem: RAMAnimatedTabBarItem {

    override init() {
        super.init()
        image = UIImage(named: "event.png")
        title = "Events"
        animation = RAMBounceAnimation()
    }
}

iconView is nil. why not checking it before unwrapping...

2016-11-15 17 12 42

JustinM1 commented 7 years ago

For most use cases you don't need to subclass. I got it working in code by doing it this way.

let tabBarIconHome: RAMAnimatedTabBarItem = RAMAnimatedTabBarItem(title: "Title1", image: #imageLiteral(resourceName: "image").withRenderingMode(.alwaysOriginal), selectedImage: #imageLiteral(resourceName: "image"))
        tabBarIconHome.animation = RAMBounceAnimation()

let tabBarIconProfile: RAMAnimatedTabBarItem = RAMAnimatedTabBarItem(title: "title", image: #imageLiteral(resourceName: "image").withRenderingMode(.alwaysOriginal), selectedImage: #imageLiteral(resourceName: "image").withRenderingMode(.alwaysOriginal))
        tabBarIconProfile.animation = RAMBounceAnimation()

let homeNavController = UINavigationController(rootViewController: HomeVC())
    homeNavController.tabBarItem = tabBarIconHome

let profileNavController = UINavigationController(rootViewController: ProfileVC())
    profileNavController.tabBarItem = tabBarIconProfile

let tabController = RAMAnimatedTabBarController(viewControllers: [homeNavController, profileNavController])

window?.rootViewController = tabController
window?.makeKeyVisible()
0ber commented 6 years ago

This project prefer using storyboard