VLCTimeNavigationTitleView.m 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. [self.aspectRatioButton setImage:[UIImage imageNamed:@"ratioIcon"] forState:UIControlStateNormal];
  22. [self setNeedsLayout];
  23. }
  24. - (void)layoutSubviews
  25. {
  26. [super layoutSubviews];
  27. CGRect remainder = self.bounds;
  28. CGRect slice;
  29. if (!self.aspectRatioButton.hidden) {
  30. [self.aspectRatioButton sizeToFit];
  31. CGRectDivide(remainder, &slice, &remainder, CGRectGetWidth(self.aspectRatioButton.frame), CGRectMaxXEdge);
  32. self.aspectRatioButton.frame = slice;
  33. }
  34. [self.timeDisplayButton sizeToFit];
  35. CGRectDivide(remainder, &slice, &remainder, CGRectGetWidth(self.timeDisplayButton.frame), CGRectMaxXEdge);
  36. self.timeDisplayButton.frame = slice;
  37. self.positionSlider.frame = remainder;
  38. }
  39. - (void)setHideAspectRatio:(BOOL)hideAspectRatio
  40. {
  41. _hideAspectRatio = hideAspectRatio;
  42. self.aspectRatioButton.hidden = hideAspectRatio;
  43. [self setNeedsLayout];
  44. }
  45. @end