Closed DKPham closed 5 years ago
When you meet mistakes,You must provide a screenshot of the error.
Sorry. Here is the screenshot. I created another project and get the code from the example project. I want to customize the middle tab bar item to have big circle like in the demo. But it doesn't work.
And here is my code: import UIKit import ESTabBarController_swift
class BaseTabBarController : ESTabBarController, UITabBarControllerDelegate {
override func viewDidLoad() {
super.viewDidLoad()
setupTabBarViewController()
}
func setupTabBarViewController() {
self.delegate = delegate
self.title = "Irregularity"
self.tabBar.shadowImage = UIImage(named: "transparent")
self.tabBar.backgroundImage = UIImage(named: "background_dark")
self.shouldHijackHandler = {
tabbarController, viewController, index in
if index == 2 {
return true
}
return false
}
self.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)
self.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(ExampleIrregularityBasicContentView(), title: "Home", image: UIImage(named: "home"), selectedImage: UIImage(named: "home_1"))
v2.tabBarItem = ESTabBarItem.init(ExampleIrregularityBasicContentView(), title: "Find", image: UIImage(named: "find"), selectedImage: UIImage(named: "find_1"))
v3.tabBarItem = ESTabBarItem.init(ExampleIrregularityContentView(), title: nil, image: UIImage(named: "photo_verybig"), selectedImage: UIImage(named: "photo_verybig"))
v4.tabBarItem = ESTabBarItem.init(ExampleIrregularityBasicContentView(), title: "Favor", image: UIImage(named: "favor"), selectedImage: UIImage(named: "favor_1"))
v5.tabBarItem = ESTabBarItem.init(ExampleIrregularityBasicContentView(), title: "Me", image: UIImage(named: "me"), selectedImage: UIImage(named: "me_1"))
viewControllers = [v1, v2, v3, v4, v5]
}
}
.......... There's a big photo in the demo, so you can look it up, or you can make a big icon
When I first used it, I also encountered the same mistake as you. The reason is as follows: there is something wrong with the size of your icon. You can check the icon in the demo of the author
I used all the assets that is provided by the example project. The big circle for middle item still don't show up...I can send you the project to check it
I've seen icon size problems before, but I haven't seen you......
Can i send you my project? please help me if you know how to fix this.
My email is hellohchen@163.com, you can send it to the email
Thank you so much. I'm sending you right now. Have you receive it?
I find you are copying a little less code, TabBar needs to refresh the layout, to implement method: override func updateLayout()
Thank you. I put this code in ExampleIrregularityContentView class and it work. Again. Thank you so much for helping
It's nothing.
I owed you big one. Cause i have been stuck with this problem for like a week. I'm so happy that it work now.
What is your xcode version? When I was at xcode10.2.1, pop had animation, but in xode10.3, pop did not have animation but instead displayed directly, and controller set hidesbottombarwhenput = true
I download the example project but can't run it. It just said "Build Succeed" but it doesn't launch into simulator or device. Please help