ESTabBarController
ESTabBarController copied to clipboard
Highlight and sizing issues with action button (“hijack” item)
In implementing an action-style (button) item in my tab bar, I've observed a couple of problems with size and user interaction that I've had to work around in a subclass:
- the button does not indicate a highlight state during touch down.
- the icon is drawn at the default tab bar item size, rather than the icon's natural size.
These problems are corrected with the following subclass:
class LargeTabBarContentView: ESTabBarItemContentView {
override func highlightAnimation(animated: Bool, completion: (() -> Void)?) {
imageView.tintColor = highlightIconColor
completion?()
}
override func dehighlightAnimation(animated: Bool, completion: (() -> Void)?) {
imageView.tintColor = iconColor
completion?()
}
override func updateLayout() {
super.updateLayout()
imageView.sizeToFit()
imageView.center = center
}
}
The lack of highlighting seems to be an obvious bug.
The lack of natural button resizing would be better controlled through a flag (e.g. sizeToFitIcon or such) rather than need a layout override.
Set BasicTabBarItemContentView's renderingMode propertie to alwaysOriginal. You can see the surprise~
Can you elaborate? I presume you mean ESTabBarItemContentView (there is no such class as BasicTabBarItemContentView). Even so, setting renderingMode = .alwaysOriginal seems to have no such effect—the icon is still drawn small, and is receives no highlight colour.