VLCTimeNavigationTitleView.m 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*****************************************************************************
  2. * VLCTimeNavigationTitleView.m
  3. * VLC for iOS
  4. *****************************************************************************
  5. * Copyright (c) 2017 VideoLAN. All rights reserved.
  6. * $Id$
  7. *
  8. * Author: Tobias Conradi <videolan # tobias-conradi.de>
  9. Carola Nitz <nitz.carola # gmail.com>
  10. *
  11. * Refer to the COPYING file of the official project for license.
  12. *****************************************************************************/
  13. #import "VLCTimeNavigationTitleView.h"
  14. @import CoreText.SFNTLayoutTypes;
  15. @implementation VLCTimeNavigationTitleView
  16. - (void)awakeFromNib {
  17. self.minimizePlaybackButton.accessibilityLabel = NSLocalizedString(@"MINIMIZE_PLAYBACK_VIEW", nil);
  18. self.aspectRatioButton.accessibilityLabel = NSLocalizedString(@"VIDEO_ASPECT_RATIO_BUTTON", nil);
  19. [self.aspectRatioButton setImage:[UIImage imageNamed:@"ratioIcon"] forState:UIControlStateNormal];
  20. [self setupTimeDisplayFont];
  21. [super awakeFromNib];
  22. }
  23. /**
  24. Use a monospace variant for the digits so the label's width does not jitter as the numbers change.
  25. */
  26. - (void)setupTimeDisplayFont
  27. {
  28. UIFontDescriptor *descriptor = self.timeDisplayButton.titleLabel.font.fontDescriptor;
  29. NSDictionary *featureSettings = @{
  30. UIFontFeatureTypeIdentifierKey: @(kNumberSpacingType),
  31. UIFontFeatureSelectorIdentifierKey: @(kMonospacedNumbersSelector)
  32. };
  33. NSDictionary *attributes = @{ UIFontDescriptorFeatureSettingsAttribute: @[featureSettings] };
  34. UIFontDescriptor *newDescriptor = [descriptor fontDescriptorByAddingAttributes: attributes];
  35. UIFont *newFont = [UIFont fontWithDescriptor:newDescriptor size:0];
  36. self.timeDisplayButton.titleLabel.font = newFont;
  37. }
  38. @end