UIBarButtonItem+Theme.m 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*****************************************************************************
  2. * UIBarButtonItem+Theme.m
  3. * VLC for iOS
  4. *****************************************************************************
  5. * Copyright (c) 2013-2015 VideoLAN. All rights reserved.
  6. * $Id$
  7. *
  8. * Authors: Felix Paul Kühne <fkuehne # videolan.org>
  9. * Fabio Ritrovato <sephiroth87 # videolan.org>
  10. *
  11. * Refer to the COPYING file of the official project for license.
  12. *****************************************************************************/
  13. @implementation UIBarButtonItem (ThemedButtons)
  14. + (UIBarButtonItem *)themedBackButtonWithTarget:(id)target andSelector:(SEL)selector
  15. {
  16. UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"BUTTON_BACK", nil)
  17. style:UIBarButtonItemStyleBordered
  18. target:target
  19. action:selector];
  20. backButton.tintColor = [UIColor whiteColor];
  21. NSShadow *shadow = [[NSShadow alloc] init];
  22. [backButton setTitleTextAttributes:@{NSShadowAttributeName : shadow, NSForegroundColorAttributeName : [UIColor whiteColor]} forState:UIControlStateNormal];
  23. [backButton setTitlePositionAdjustment:UIOffsetMake(3, 0) forBarMetrics:UIBarMetricsDefault];
  24. return backButton;
  25. }
  26. + (UIBarButtonItem *)themedRevealMenuButtonWithTarget:(id)target andSelector:(SEL)selector
  27. {
  28. /* After day 354 of the year, the usual VLC cone is replaced by another cone
  29. * wearing a Father Xmas hat.
  30. * Note: this icon doesn't represent an endorsement of The Coca-Cola Company
  31. * and should not be confused with the idea of religious statements or propagation there off
  32. */
  33. NSCalendar *gregorian =
  34. [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
  35. NSUInteger dayOfYear = [gregorian ordinalityOfUnit:NSDayCalendarUnit inUnit:NSYearCalendarUnit forDate:[NSDate date]];
  36. UIImage *icon;
  37. if (dayOfYear >= 354)
  38. icon = [UIImage imageNamed:@"vlc-xmas"];
  39. else
  40. icon = [UIImage imageNamed:@"menuCone"];
  41. UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithImage:icon style:UIBarButtonItemStyleBordered target:target action:selector];
  42. menuButton.tintColor = [UIColor whiteColor];
  43. menuButton.accessibilityLabel = NSLocalizedString(@"OPEN_VLC_MENU", nil);
  44. menuButton.isAccessibilityElement = YES;
  45. return menuButton;
  46. }
  47. + (UIBarButtonItem *)themedDarkToolbarButtonWithTitle:(NSString*)title target:(id)target andSelector:(SEL)selector
  48. {
  49. UIBarButtonItem *button = [[UIBarButtonItem alloc] initWithTitle:title style:UIBarButtonItemStyleBordered target:target action:selector];
  50. button.tintColor = [UIColor whiteColor];
  51. return button;
  52. }
  53. @end