Permalink
Browse files

iOS 4 Bugs fixed, temporary workaround for gradient-crash on iOS 4

  • Loading branch information...
1 parent 0c672b9 commit a2c5fbf89e07fcf6343707899193a0371abcb2a9 @myell0w myell0w committed May 4, 2012
Showing with 21 additions and 7 deletions.
  1. +18 −7 NGTabBarController/NGTabBar.m
  2. +3 −0 NGTabBarController/NGTabBarController.m
@@ -302,15 +302,26 @@ - (void)createGradient {
UIColor *baseColor = self.tintColor;
CGFloat hue, saturation, brightness, alpha;
+ NSArray *colors = nil;
- // TODO: Only works on iOS 5
- [baseColor getHue:&hue saturation:&saturation brightness:&brightness alpha:&alpha];
+ // TODO: This is a temporary workaround because getHue:saturation:brightness:alpha: is iOS 5 and up
+ // We need a better way of drawing a TabBar-Gradient
+ if ([baseColor respondsToSelector:@selector(getHue:saturation:brightness:alpha:)]) {
+ [baseColor getHue:&hue saturation:&saturation brightness:&brightness alpha:&alpha];
+
+ colors = [NSArray arrayWithObjects:
+ [UIColor colorWithHue:hue saturation:saturation brightness:brightness+0.2 alpha:alpha],
+ [UIColor colorWithHue:hue saturation:saturation brightness:brightness+0.15 alpha:alpha],
+ [UIColor colorWithHue:hue saturation:saturation brightness:brightness+0.1 alpha:alpha],
+ baseColor, nil];
+ } else {
+ colors = [NSArray arrayWithObjects:
+ baseColor,
+ baseColor,
+ baseColor,
+ baseColor, nil];
+ }
- NSArray *colors = [NSArray arrayWithObjects:
- [UIColor colorWithHue:hue saturation:saturation brightness:brightness+0.2 alpha:alpha],
- [UIColor colorWithHue:hue saturation:saturation brightness:brightness+0.15 alpha:alpha],
- [UIColor colorWithHue:hue saturation:saturation brightness:brightness+0.1 alpha:alpha],
- baseColor, nil];
NSUInteger colorsCount = colors.count;
CGColorSpaceRef colorSpace = CGColorGetColorSpace([[colors objectAtIndex:0] CGColor]);
@@ -253,6 +253,8 @@ - (void)setViewControllers:(NSArray *)viewControllers {
viewController.view.clipsToBounds = YES;
}
+ [self layout];
+
if (self.selectedIndex == NSNotFound && _viewControllers.count > 0) {
[self.view addSubview:[[_viewControllers objectAtIndex:0] view]];
self.selectedIndex = 0;
@@ -573,6 +575,7 @@ - (void)setupTabBarForPosition:(NGTabBarPosition)position {
self.tabBar.frame = frame;
self.tabBar.autoresizingMask = autoresizingMask;
+ [self.tabBar setNeedsLayout];
for (NSUInteger index = 0; index < self.viewControllers.count; index++) {
UIViewController *viewController = [self.viewControllers objectAtIndex:index];

0 comments on commit a2c5fbf

Please sign in to comment.