VLCFrostedGlasView.m 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*****************************************************************************
  2. * VLCFrostedGlasView.m
  3. * VLC for iOS
  4. *****************************************************************************
  5. * Copyright (c) 2013-2014 VideoLAN. All rights reserved.
  6. * $Id$
  7. *
  8. * Authors: Carola Nitz <nitz.carola # googlemail.com>
  9. *
  10. * Refer to the COPYING file of the official project for license.
  11. *****************************************************************************/
  12. #import "VLCFrostedGlasView.h"
  13. @interface VLCFrostedGlasView ()
  14. @property (nonatomic) UIToolbar *toolbar;
  15. @property (nonatomic) UIImageView *imageview;
  16. @end
  17. @implementation VLCFrostedGlasView
  18. - (id)initWithCoder:(NSCoder *)aDecoder
  19. {
  20. self = [super initWithCoder:aDecoder];
  21. if (self)
  22. [self setupView];
  23. return self;
  24. }
  25. - (instancetype)initWithFrame:(CGRect)frame
  26. {
  27. self = [super initWithFrame:frame];
  28. if (self)
  29. [self setupView];
  30. return self;
  31. }
  32. - (void)setupView
  33. {
  34. [self setClipsToBounds:YES];
  35. if (SYSTEM_RUNS_IOS7_OR_LATER) {
  36. if (![self toolbar]) {
  37. [self setToolbar:[[UIToolbar alloc] initWithFrame:[self bounds]]];
  38. [self.layer insertSublayer:[self.toolbar layer] atIndex:0];
  39. [self.toolbar setBarStyle:UIBarStyleBlack];
  40. }
  41. } else {
  42. if(![self imageview]) {
  43. [self setImageview:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"playbackControllerBg"]]];
  44. [self insertSubview:self.imageview atIndex:0];
  45. }
  46. }
  47. }
  48. - (void)layoutSubviews {
  49. [super layoutSubviews];
  50. if (SYSTEM_RUNS_IOS7_OR_LATER) {
  51. [self.toolbar setFrame:[self bounds]];
  52. } else {
  53. [self.imageview setFrame:[self bounds]];
  54. }
  55. }
  56. @end