VLCFrostedGlasView.m 2.02 KB
Newer Older
1 2 3 4
/*****************************************************************************
 * VLCFrostedGlasView.m
 * VLC for iOS
 *****************************************************************************
5
 * Copyright (c) 2013-2015 VideoLAN. All rights reserved.
6 7 8
 * $Id$
 *
 * Authors: Carola Nitz <nitz.carola # googlemail.com>
9
 *          Felix Paul Kühne <fkuehne # videolan # org>
10 11 12 13 14 15 16
 *
 * Refer to the COPYING file of the official project for license.
 *****************************************************************************/

#import "VLCFrostedGlasView.h"

@interface VLCFrostedGlasView ()
17 18 19
{
    BOOL _usingToolbarHack;
}
20

21
#if TARGET_OS_IOS
22
@property (nonatomic) UIToolbar *toolbar;
23
@property (nonatomic) UIImageView *imageview;
24
#endif
25
@property (nonatomic)  UIVisualEffectView *effectView;
26 27 28 29 30 31 32 33

@end

@implementation VLCFrostedGlasView

- (id)initWithCoder:(NSCoder *)aDecoder
{
    self = [super initWithCoder:aDecoder];
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
    if (self)
        [self setupView];

    return self;
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];

    if (self)
        [self setupView];

    return self;
}

- (void)setupView
{
    [self setClipsToBounds:YES];
Felix Paul Kühne's avatar
Felix Paul Kühne committed
53

54
#if TARGET_OS_IOS
55 56 57 58 59
    _effectView = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleDark]];
    _effectView.frame = self.bounds;
    _effectView.clipsToBounds = YES;
    _effectView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    [self insertSubview:_effectView atIndex:0];
60 61 62 63
#else
    _effectView = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleDark]];
    _effectView.frame = self.bounds;
    _effectView.clipsToBounds = YES;
64
    _effectView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
65
    [self insertSubview:_effectView atIndex:0];
66
#endif
67 68
}

69
#if TARGET_OS_IOS
70 71
- (void)layoutSubviews {
    [super layoutSubviews];
72 73 74
    if (_usingToolbarHack) {
        [self.toolbar setFrame:[self bounds]];
    }
75
}
76
#endif
77

78
@end