Skip to content
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

Enhanced PrettyTabBar #12

Open
wants to merge 59 commits into
base: master
Choose a base branch
from

Conversation

echoz
Copy link
Contributor

@echoz echoz commented May 6, 2012

This is a huge ass commit. Really sorry for the multiple commits. Should've rebased it first.

That aside, this pull request basically is about an enhanced UITabBar. It has the following features,

  1. Shadows that can be configured to appear upwards or downwards
  2. Switchable representation of the buttons that appear in the TabBar either between the Apple defaults (UITabBarButton) or the PrettyKit highly configurable version (PrettyTabBarButton)

This new TabBar is should be a drop in replacement while supporting all callbacks that is expected of a UITabBar. Has been tested with UITabBarControllers to work perfectly. No changes needed to make this work with existing projects, just use PrettyTabBar instead of an UITabBar.

The new class PrettyTabBarButton itself provides more configuration than previously possible for normal UITabBars while still support iOS 4.3.

Some of the configurable options include,

  • Title font
  • Title shadow offset and opacity
  • Title color
  • Badge border color
  • Badge font
  • Badge text color
  • Badge inner gradient start and end colors
  • Image to use for the highlight in the select state or;
  • Gradient start and end colors for the highlight in select state
  • Badge shadow offset and opacity
  • Image to use when the button is selected or;
  • Gradient start and end colors for the "tint" on the image to use when button is selected

While these options are configurable on the TabBarButton, they are really only settable via usage of the PrettyTabBar as there is tight coupling between both classes (also how Apple seems to do it).

PrettyTabBarButton draws everything using Core Graphics.

Also added some new methods to the PrettyDrawing class.

echoz added 30 commits May 4, 2012 03:27
This uses an internal representation as well as reflecting it in the view hierarchy to allow more configurable tab bar buttons.
also corrected logic flow for selection of tabbarbuttons
…e obvious.

setting of badge value does the correct things by copying as well as setting that a redraw is needed.
…nded rectangle

corresponding methods to draw rounded rectangles with a solid fill color and with a gradient.

abstracted gradient drawing into a method that will draw to a context you specify. also used a more primitive way of dealing with the colors

UIColor additions to deal with getting of converted RGB components in the absence of colorspace conversion mechanics
also modified font style to match defat UITabBarButtons'
removed sending super observevalueforkeypath. technically not needed.
@vicpenap
Copy link
Owner

vicpenap commented May 7, 2012

Done!

I can't make badges work, though :/

@echoz
Copy link
Contributor Author

echoz commented May 7, 2012

Weird. I've gotten them to work by modifying the View Controller's UITabBarItem's badgeValue.

PrettyTabBar listens for changes to those and changes the value accordingly.

@vicpenap
Copy link
Owner

vicpenap commented May 7, 2012

I've tried, before my changes, that way and also through the IB's field, and it didn't seem to work :/. I haven't tried hard, though.

@echoz
Copy link
Contributor Author

echoz commented May 7, 2012

Weird. Works for me.

Insert this at line 34 of the appdelegate:
((UIViewController *)[self.tabBarController.viewControllers objectAtIndex:0]).tabBarItem.badgeValue = @"1";

@vicpenap
Copy link
Owner

vicpenap commented May 7, 2012

I did that from the view controller (self.tabBarItem), that's why it didn't work for me.

@echoz
Copy link
Contributor Author

echoz commented May 7, 2012

Ah! Okay. I think I know what to do for this. :)

optionally aggressively passes on KVO observation to super class through the use of a @Try..@catch block to prevent exceptions.
@echoz
Copy link
Contributor Author

echoz commented May 7, 2012

i just checked apple's implementation, it also doesn't seem to reflect the change in the badge value.

Further investigation says that if you try to set the badgeValue during viewDidLoad, it doesn't seem to work. However anytime else after the UIViewController has loaded, calling self.tabBarItem.badgeValue = something should work fine and update the tabbar.

@echoz
Copy link
Contributor Author

echoz commented May 14, 2012

Regarding #13:

Translucent tabbars would only probably work if they are not part of the UITabBarController as the content view of the tabbar controller will not resize to encompass the area lost (a la translucent UINavigationBar).

Don't really see a point beyond the fact that this might introduce bad UI design.

Btw, added some more commits previously. Not sure if you've merged them.

@vicpenap
Copy link
Owner

I've just merged them.

@vicpenap
Copy link
Owner

Hi @echoz. Happy to see tabbar is still alive :D. Do you have any clue about the issue with predefined IB buttons? I mean this: #12 (comment).

@echoz
Copy link
Contributor Author

echoz commented May 29, 2012

I can't give a definitive answer (because I haven't really had the time to look into it), but as of this moment I don't think its possible to use predefined buttons for this :/

@vicpenap
Copy link
Owner

Well, as a last resort we could add a note in documentation to explain that.

@echoz
Copy link
Contributor Author

echoz commented May 29, 2012

Yeah. I guess that'll do for now. Will look into it when I have more time on my hands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants