eggswift / ESTabBarController

:octocat: ESTabBarController is a Swift model for customize UI, badge and adding animation to tabbar items. Support lottie!
MIT License
5.17k stars 578 forks source link

Big button doesn't work #204

Closed vietnguyen09 closed 5 years ago

vietnguyen09 commented 5 years ago

Hi there,

I download and run ESExample fine but I don't know why when I create my own project and use code from Example, my Lage button still small??

image

My expectation

image

Here is my code

AppDelegate.swift

let TabbarNavigationController = ViewController.customIrregularityStyle(delegate: nil)
self.window?.rootViewController = TabbarNavigationController    

ViewController.swift

static func customIrregularityStyle(delegate: UITabBarControllerDelegate?) -> NavigationController {
    let tabBarController = ESTabBarController()
    tabBarController.delegate = delegate
    tabBarController.title = "Irregularity"
    tabBarController.tabBar.shadowImage = UIImage(named: "transparent")
    tabBarController.tabBar.backgroundImage = UIImage(named: "background_dark")
    tabBarController.shouldHijackHandler = {
        tabbarController, viewController, index in
        if index == 2 {
            return true
        }
        return false
    }
    tabBarController.didHijackHandler = {
        [weak tabBarController] tabbarController, viewController, index in

        DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
            let alertController = UIAlertController.init(title: nil, message: nil, preferredStyle: .actionSheet)
            let takePhotoAction = UIAlertAction(title: "Take a photo", style: .default, handler: nil)
            alertController.addAction(takePhotoAction)
            let selectFromAlbumAction = UIAlertAction(title: "Select from album", style: .default, handler: nil)
            alertController.addAction(selectFromAlbumAction)
            let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil)
            alertController.addAction(cancelAction)
            tabBarController?.present(alertController, animated: true, completion: nil)
        }
    }

    let v1 = ExampleViewController()
    let v2 = ExampleViewController()
    let v3 = ExampleViewController()
    let v4 = ExampleViewController()
    let v5 = ExampleViewController()

    v1.tabBarItem = ESTabBarItem.init(IrregularityBasicContentView(), title: "Home", image: UIImage(named: "home"), selectedImage: UIImage(named: "home_1"))
    v2.tabBarItem = ESTabBarItem.init(IrregularityBasicContentView(), title: "Find", image: UIImage(named: "find"), selectedImage: UIImage(named: "find_1"))
    v3.tabBarItem = ESTabBarItem.init(IrregularityBasicContentView(), title: nil, image: UIImage(named: "photo_verybig"), selectedImage: UIImage(named: "photo_verybig"))
    v4.tabBarItem = ESTabBarItem.init(IrregularityBasicContentView(), title: "Favor", image: UIImage(named: "favor"), selectedImage: UIImage(named: "favor_1"))
    v5.tabBarItem = ESTabBarItem.init(IrregularityBasicContentView(), title: "Me", image: UIImage(named: "me"), selectedImage: UIImage(named: "me_1"))

    tabBarController.viewControllers = [v1, v2, v3, v4, v5]

    let navigationController = NavigationController.init(rootViewController: tabBarController)
    tabBarController.title = "Example"
    return navigationController
}

Any idea?