Skip to content
This repository
Browse code

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

  • Loading branch information...
commit a2c5fbf89e07fcf6343707899193a0371abcb2a9 1 parent 0c672b9
Matthias Tretter myell0w authored
25 NGTabBarController/NGTabBar.m
@@ -302,15 +302,26 @@ - (void)createGradient {
302 302
303 303 UIColor *baseColor = self.tintColor;
304 304 CGFloat hue, saturation, brightness, alpha;
  305 + NSArray *colors = nil;
305 306
306   - // TODO: Only works on iOS 5
307   - [baseColor getHue:&hue saturation:&saturation brightness:&brightness alpha:&alpha];
  307 + // TODO: This is a temporary workaround because getHue:saturation:brightness:alpha: is iOS 5 and up
  308 + // We need a better way of drawing a TabBar-Gradient
  309 + if ([baseColor respondsToSelector:@selector(getHue:saturation:brightness:alpha:)]) {
  310 + [baseColor getHue:&hue saturation:&saturation brightness:&brightness alpha:&alpha];
  311 +
  312 + colors = [NSArray arrayWithObjects:
  313 + [UIColor colorWithHue:hue saturation:saturation brightness:brightness+0.2 alpha:alpha],
  314 + [UIColor colorWithHue:hue saturation:saturation brightness:brightness+0.15 alpha:alpha],
  315 + [UIColor colorWithHue:hue saturation:saturation brightness:brightness+0.1 alpha:alpha],
  316 + baseColor, nil];
  317 + } else {
  318 + colors = [NSArray arrayWithObjects:
  319 + baseColor,
  320 + baseColor,
  321 + baseColor,
  322 + baseColor, nil];
  323 + }
308 324
309   - NSArray *colors = [NSArray arrayWithObjects:
310   - [UIColor colorWithHue:hue saturation:saturation brightness:brightness+0.2 alpha:alpha],
311   - [UIColor colorWithHue:hue saturation:saturation brightness:brightness+0.15 alpha:alpha],
312   - [UIColor colorWithHue:hue saturation:saturation brightness:brightness+0.1 alpha:alpha],
313   - baseColor, nil];
314 325 NSUInteger colorsCount = colors.count;
315 326 CGColorSpaceRef colorSpace = CGColorGetColorSpace([[colors objectAtIndex:0] CGColor]);
316 327
3  NGTabBarController/NGTabBarController.m
@@ -253,6 +253,8 @@ - (void)setViewControllers:(NSArray *)viewControllers {
253 253 viewController.view.clipsToBounds = YES;
254 254 }
255 255
  256 + [self layout];
  257 +
256 258 if (self.selectedIndex == NSNotFound && _viewControllers.count > 0) {
257 259 [self.view addSubview:[[_viewControllers objectAtIndex:0] view]];
258 260 self.selectedIndex = 0;
@@ -573,6 +575,7 @@ - (void)setupTabBarForPosition:(NGTabBarPosition)position {
573 575
574 576 self.tabBar.frame = frame;
575 577 self.tabBar.autoresizingMask = autoresizingMask;
  578 + [self.tabBar setNeedsLayout];
576 579
577 580 for (NSUInteger index = 0; index < self.viewControllers.count; index++) {
578 581 UIViewController *viewController = [self.viewControllers objectAtIndex:index];

0 comments on commit a2c5fbf

Please sign in to comment.
Something went wrong with that request. Please try again.