VLCFrostedGlasView.m 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. [self insertSubview:_effectView atIndex:0];
  51. #endif
  52. }
  53. #if TARGET_OS_IOS
  54. - (void)layoutSubviews {
  55. [super layoutSubviews];
  56. [self.toolbar setFrame:[self bounds]];
  57. }
  58. #endif
  59. @end