VLCFrostedGlasView.m 1.8 KB

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