vicpenap / PrettyKit

PrettyKit for iOS is a small set of new widgets and UIKit subclasses that gives you a deeper UIKit customization. You will be able to change their background color, add gradients, shadows, etc.
http://vicpenap.github.com/PrettyKit
Other
1.22k stars 155 forks source link

Enhanced PrettyTabBar #12

Open echoz opened 12 years ago

echoz commented 12 years ago

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,

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 commented 12 years ago

Okay. There is a lot of power inherent in its customizability. I made a small example without screwing around too much with it.

PrettyTabBar Enhanced Example

There is still much to do, like adding the glossy effect and all that, but this should be a good jumping off point.

vicpenap commented 12 years ago

Wow, this looks great! I'm really looking forward to trying it. Probably tomorrow. In the meanwhile, you could do a more detailed example of use if you want to :).

Thanks a lot!

echoz commented 12 years ago

Sure thing. Will probably work on that examples much later. Its been a long weekend. ;)

vicpenap commented 12 years ago

Of course! No hurries at all :)

echoz commented 12 years ago

Terribly sorry for the additional commits. realised the way i was laying out subviews wasn't ideal. so rewrote the implementation. this should be much better :)

These should be the last commits.

vicpenap commented 12 years ago

Hi!

I've merged your changes into a new local branch, but it isn't working as expected. I've just launched the example app, with no changes, and it has crashed in line 230 of PrettyTabBar.m: [item removeObserver:self forKeyPath:@"badgeValue"];

I've commented that line, just to make it run, but there are no tabbar buttons, as seen in the included screenshot.

I see you're still working on the feature, so I'll wait until you're finished :)

echoz commented 12 years ago

Hello hello. fixed the bug. sorry about that. :/

vicpenap commented 12 years ago

Great!

It works really great. But, when setting a predefined item from Interface Builder, it won't show.

But creating a custom one works great, and this work you're doing looks very powerful. It would be great, by the way, to tint images in not selected items with the same gray level of the text.

Another thing: I think it would be a good idea to remove default values from PrettyTabBarButtons because, as far as I know, they're always set from PrettyTabBar. This will remove duplicity, and it will be faster to change those default values in the future :)

Last one: I've changed this default values to better mimic the default UITabBar:

echoz commented 12 years ago

Yeah. Tinting was a problem to figure out. Will probably commit some other changes at a later date, but this should be ready for use.

Yeah, I was also thinking about all the default values in the PrettyTabBarButton. Just added it to be consistent with the project's settings.

Not too sure what you mean by setting predefined item that won't show in interface builder

vicpenap commented 12 years ago

A picture is worth a thousand words :)

echoz commented 12 years ago

Ahh! Hmm. That's quite a challenge to get working. I'd probably work on that next weekend. (PrettyKit has been a fun 2 weekends of hacks. :))

But yeah, I guess custom stuff for now.

vicpenap commented 12 years ago

Hahaha yeah, I'd love to have more time to spend on it too.

I've pushed a new branch called tabbar, with your changes included, and some changes I've made on yours :D. Including removing the default values from tabbar button, a little bit of refactoring, and tinting the item's icon to the same text color when not selected.

I won't merge it with the master branch yet, as I think we can improve it even more :D. But I'm really looking forward to releasing a new version of PrettyKit with this nice tabbar :D

Cheers!

vicpenap commented 12 years ago

Well, I forgot to add those changes :). I'm doing it right now.

echoz commented 12 years ago

That'll be really exciting to work on. :)

Lets make this really Pretty (pun :P)

vicpenap commented 12 years ago

Done!

I can't make badges work, though :/

echoz commented 12 years ago

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 commented 12 years ago

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 commented 12 years ago

Weird. Works for me.

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

vicpenap commented 12 years ago

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

echoz commented 12 years ago

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

echoz commented 12 years ago

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 commented 12 years ago

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 commented 12 years ago

I've just merged them.

vicpenap commented 12 years ago

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: https://github.com/vicpenap/PrettyKit/pull/12#issuecomment-5546144.

echoz commented 12 years ago

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 commented 12 years ago

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

echoz commented 12 years ago

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