Customizing UITabBar (Or, tenuous principles to UIKit customization)
UITabBarController is cool, but (un)fortunately it has only one flavor. People might resort to brute-force, re-creating the entire controller from scratch. This is extremely troublesome: a) it takes a lot more effort; b) it needs reverse engineering; c) quirk-for-quirk compatibility is not fun.
Most of the time, you’ll want to skin the thing, not create a new thing that works like the old thing, and then skin that new thing. If you can’t skin it (because the view hierarchies are private) thru UIKit, work around UIKit. Work from Core Animation.
Use a fully black
CALayer on the tab bar’s
maskLayer in a custom subclass. Then use
NSKeyedArchiver to swizzle the tab bar (thanks
cocoa-unbound) with your own subclass.
If things proceed correctly, you’ll get a tab bar that is transparent, but still handles all the touch events, and works “correctly” in all cases. Now go on and intercept all its delegate calls, reconfiguring your own faux tab bar overlay whenever necessary.
- Don’t hack view hierarchies; if it looks hack-ish, there’s probably an easier way.
- Stealing Apple code, and avoiding writing code, is extremely fun.