VLCSlider.m 2.86 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
/*****************************************************************************
 * VLCSlider.m
 * VLC for iOS
 *****************************************************************************
 * Copyright (c) 2013 VideoLAN. All rights reserved.
 * $Id$
 *
 * Authors: Felix Paul Kühne <fkuehne # videolan.org>
 *
 * Refer to the COPYING file of the official project for license.
 *****************************************************************************/
Felix Paul Kühne's avatar
Felix Paul Kühne committed
12 13 14 15 16 17 18

#import "VLCSlider.h"

@implementation VLCOBSlider

- (void)awakeFromNib
{
19 20 21
    self.accessibilityLabel = NSLocalizedString(@"PLAYBACK_POSITION", nil);
    self.isAccessibilityElement = YES;

22
    if (SYSTEM_RUNS_IOS7_OR_LATER)
23 24
        [self setThumbImage:[UIImage imageNamed:@"modernSliderKnob"] forState:UIControlStateNormal];
    else {
25 26 27 28 29 30
        self.minimumValueImage = [UIImage imageNamed:@"sliderminiValue"];
        self.maximumValueImage = [UIImage imageNamed:@"slidermaxValue"];
        [self setMinimumTrackImage:[UIImage imageNamed:@"sliderminimumTrack"] forState:UIControlStateNormal];
        [self setMaximumTrackImage:[UIImage imageNamed:@"slidermaximumTrack"] forState:UIControlStateNormal];
        [self setThumbImage:[UIImage imageNamed:@"ballSlider"] forState:UIControlStateNormal];
        [self setThumbImage:[UIImage imageNamed:@"knobSlider"] forState:UIControlStateHighlighted];
31
    }
Felix Paul Kühne's avatar
Felix Paul Kühne committed
32 33 34 35 36
}

- (CGRect)trackRectForBounds:(CGRect)bounds
{
    CGRect returnValue = [super trackRectForBounds:bounds];
37 38 39
    if (SYSTEM_RUNS_IOS7_OR_LATER)
        return returnValue;

Felix Paul Kühne's avatar
Felix Paul Kühne committed
40
    returnValue.origin.x = 5.;
41
    returnValue.origin.y = 7.;
Felix Paul Kühne's avatar
Felix Paul Kühne committed
42 43 44 45 46 47 48 49 50
    returnValue.size.width = bounds.size.width - 10.;
    return returnValue;
}

@end


@implementation VLCSlider

51 52 53 54 55 56 57 58
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
        [self setThumbImage:[UIImage imageNamed:@"modernSliderKnob"] forState:UIControlStateNormal];
    return self;
}

Felix Paul Kühne's avatar
Felix Paul Kühne committed
59 60
- (void)awakeFromNib
{
61
    if (SYSTEM_RUNS_IOS7_OR_LATER)
62 63 64 65 66 67 68 69
        [self setThumbImage:[UIImage imageNamed:@"modernSliderKnob"] forState:UIControlStateNormal];
    else {
        self.minimumValueImage = [UIImage imageNamed:@"sliderminiValue"];
        self.maximumValueImage = [UIImage imageNamed:@"slidermaxValue"];
        [self setMinimumTrackImage:[UIImage imageNamed:@"sliderminimumTrack"] forState:UIControlStateNormal];
        [self setMaximumTrackImage:[UIImage imageNamed:@"slidermaximumTrack"] forState:UIControlStateNormal];
        [self setThumbImage:[UIImage imageNamed:@"ballSlider"] forState:UIControlStateNormal];
    }
Felix Paul Kühne's avatar
Felix Paul Kühne committed
70 71 72 73 74
}

- (CGRect)trackRectForBounds:(CGRect)bounds
{
    CGRect returnValue = [super trackRectForBounds:bounds];
75 76 77
    if (SYSTEM_RUNS_IOS7_OR_LATER)
        return returnValue;

Felix Paul Kühne's avatar
Felix Paul Kühne committed
78
    returnValue.origin.x = 5.;
Felix Paul Kühne's avatar
Felix Paul Kühne committed
79
    if (!SYSTEM_RUNS_IOS7_OR_LATER)
80
        returnValue.origin.y = 7.;
Felix Paul Kühne's avatar
Felix Paul Kühne committed
81 82 83 84 85
    returnValue.size.width = bounds.size.width - 10.;
    return returnValue;
}

@end