ESTabBarController icon indicating copy to clipboard operation
ESTabBarController copied to clipboard

Highlight and sizing issues with action button (“hijack” item)

Open zygoat opened this issue 6 years ago • 2 comments
trafficstars

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:

  1. the button does not indicate a highlight state during touch down.
  2. 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.

zygoat avatar May 31 '19 19:05 zygoat

Set BasicTabBarItemContentView's renderingMode propertie to alwaysOriginal. You can see the surprise~

eggswift avatar Jun 02 '19 04:06 eggswift

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.

zygoat avatar Jun 03 '19 19:06 zygoat