VLCTimeNavigationTitleView.m 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*****************************************************************************
  2. * VLCTimeNavigationTitleView.m
  3. * VLC for iOS
  4. *****************************************************************************
  5. * Copyright (c) 2015 VideoLAN. All rights reserved.
  6. * $Id$
  7. *
  8. * Author: Tobias Conradi <videolan # tobias-conradi.de>
  9. *
  10. * Refer to the COPYING file of the official project for license.
  11. *****************************************************************************/
  12. #import "VLCTimeNavigationTitleView.h"
  13. #import "VLCSlider.h"
  14. @implementation VLCTimeNavigationTitleView
  15. -(void)awakeFromNib {
  16. if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
  17. self.positionSlider.scrubbingSpeedChangePositions = @[@(0.), @(100.), @(200.), @(300)];
  18. self.timeDisplayButton.isAccessibilityElement = YES;
  19. self.aspectRatioButton.accessibilityLabel = NSLocalizedString(@"VIDEO_ASPECT_RATIO_BUTTON", nil);
  20. self.aspectRatioButton.isAccessibilityElement = YES;
  21. if (SYSTEM_RUNS_IOS7_OR_LATER) {
  22. [self.aspectRatioButton setImage:[UIImage imageNamed:@"ratioIcon"] forState:UIControlStateNormal];
  23. } else {
  24. [self.aspectRatioButton setBackgroundImage:[UIImage imageNamed:@"ratioButton"] forState:UIControlStateNormal];
  25. [self.aspectRatioButton setBackgroundImage:[UIImage imageNamed:@"ratioButtonHighlight"] forState:UIControlStateHighlighted];
  26. }
  27. [self setNeedsLayout];
  28. }
  29. - (void)layoutSubviews
  30. {
  31. [super layoutSubviews];
  32. CGRect remainder = self.bounds;
  33. CGRect slice;
  34. if (!self.aspectRatioButton.hidden) {
  35. [self.aspectRatioButton sizeToFit];
  36. CGRectDivide(remainder, &slice, &remainder, CGRectGetWidth(self.aspectRatioButton.frame), CGRectMaxXEdge);
  37. self.aspectRatioButton.frame = slice;
  38. }
  39. [self.timeDisplayButton sizeToFit];
  40. CGRectDivide(remainder, &slice, &remainder, CGRectGetWidth(self.timeDisplayButton.frame), CGRectMaxXEdge);
  41. self.timeDisplayButton.frame = slice;
  42. self.positionSlider.frame = remainder;
  43. }
  44. - (void)setHideAspectRatio:(BOOL)hideAspectRatio
  45. {
  46. _hideAspectRatio = hideAspectRatio;
  47. self.aspectRatioButton.hidden = hideAspectRatio;
  48. [self setNeedsLayout];
  49. }
  50. @end