-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TabsController - Update titles of tabs looks wrong #1044
Comments
That is because the tabs are being shrunk down. Have you tried the tabs with the scrolling option which should avoid such an issue? |
We also enabled scrolling behaviour by default, instead of automatic, but then the tab bar is not the full width, if the tab titles are not long enough.. |
I'll take a look at your sample project. Thank you! |
Give this a try, Material 2.13.7. I updated your code as follows: import UIKit
import Material
import Motion
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let viewControllers = [
makeViewController(backgroundColor: .red),
makeViewController(backgroundColor: .green),
makeViewController(backgroundColor: .blue),
makeViewController(backgroundColor: .yellow)
]
let tabsController = TabsController(viewControllers: viewControllers)
tabsController.tabBarAlignment = .top
tabsController.tabBar.dividerAlignment = .bottom
tabsController.tabBar.lineHeight = 2
tabsController.tabBar.heightPreset = .small
addChildViewController(tabsController)
view.addSubview(tabsController.view)
view.layout(tabsController.view).edges(top: 50)
Motion.delay(3) {
viewControllers.first?.tabItem.title = "abcdef (10) really long"
tabsController.tabBar.setNeedsLayout()
tabsController.tabBar.layoutIfNeeded()
}
}
func makeViewController(backgroundColor: UIColor) -> UIViewController {
let vc = UIViewController()
vc.view.backgroundColor = backgroundColor
vc.tabItem.title = "abcdef"
return vc
}
} I made your text longer and used Motion to set a time delay. As well, for the edges layout, you can do this, and the rest of the values are defaulted to view.layout(tabsController.view).edges(top: 50) Thank you for sharing this issue and if you have any further trouble, please reopen this issue or create a new one. |
Thank you, we will try it out today! |
We tried it out, with your example, |
Hmmm... I will try your sample again. |
I am not sure exactly why, but the issue is your |
Hmm, if we replace the |
Weird... this is something in the String system I would think. Very interesting. |
When updating the title of the tabs in a
TabsController
, it looks weird as seen on the screenshot below. We also created an example project for you to check it out.Calling
tabBar.setNeedsLayout()
directly after the title change, it works on iPhone SE, but not on iPhone 8.MaterialTabBarTitleTest.zip
The text was updated successfully, but these errors were encountered: