UIBarButtonItem+Theme.m 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*****************************************************************************
  2. * UIBarButtonItem+Theme.m
  3. * VLC for iOS
  4. *****************************************************************************
  5. * Copyright (c) 2013-2017 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:UIBarButtonItemStylePlain
  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 = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
  34. NSUInteger dayOfYear = [gregorian ordinalityOfUnit:NSCalendarUnitDay inUnit:NSCalendarUnitYear forDate:[NSDate date]];
  35. UIImage *icon;
  36. if (dayOfYear >= 354)
  37. icon = [UIImage imageNamed:@"vlc-xmas"];
  38. else
  39. icon = [UIImage imageNamed:@"menuCone"];
  40. UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithImage:icon style:UIBarButtonItemStylePlain target:target action:selector];
  41. menuButton.tintColor = [UIColor whiteColor];
  42. menuButton.accessibilityLabel = NSLocalizedString(@"OPEN_VLC_MENU", nil);
  43. return menuButton;
  44. }
  45. + (UIBarButtonItem *)themedDarkToolbarButtonWithTitle:(NSString*)title target:(id)target andSelector:(SEL)selector
  46. {
  47. UIBarButtonItem *button = [[UIBarButtonItem alloc] initWithTitle:title style:UIBarButtonItemStylePlain target:target action:selector];
  48. button.tintColor = [UIColor whiteColor];
  49. return button;
  50. }
  51. + (UIBarButtonItem *)themedPlayAllButtonWithTarget:(id)target andSelector:(SEL)selector
  52. {
  53. UIBarButtonItem *playAllButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemPlay target:target action:selector];
  54. playAllButton.accessibilityLabel = NSLocalizedString(@"PLAY_ALL_BUTTON", nil);
  55. return playAllButton;
  56. }
  57. @end