VLCSlider.m 2.54 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.
 *****************************************************************************/
12 13 14 15 16 17 18

#import "VLCSlider.h"

@implementation VLCOBSlider

- (void)awakeFromNib
{
19
    if (SYSTEM_RUNS_IOS7_OR_LATER)
20 21
        [self setThumbImage:[UIImage imageNamed:@"modernSliderKnob"] forState:UIControlStateNormal];
    else {
22 23 24 25 26 27
        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];
28
    }
29 30 31 32 33
}

- (CGRect)trackRectForBounds:(CGRect)bounds
{
    CGRect returnValue = [super trackRectForBounds:bounds];
34 35 36
    if (SYSTEM_RUNS_IOS7_OR_LATER)
        return returnValue;

37
    returnValue.origin.x = 5.;
38
    returnValue.origin.y = 7.;
39 40 41 42 43 44 45 46 47 48 49
    returnValue.size.width = bounds.size.width - 10.;
    return returnValue;
}

@end


@implementation VLCSlider

- (void)awakeFromNib
{
50
    if (SYSTEM_RUNS_IOS7_OR_LATER)
51 52 53 54 55 56 57 58
        [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];
    }
59 60 61 62 63
}

- (CGRect)trackRectForBounds:(CGRect)bounds
{
    CGRect returnValue = [super trackRectForBounds:bounds];
64 65 66
    if (SYSTEM_RUNS_IOS7_OR_LATER)
        return returnValue;

67
    returnValue.origin.x = 5.;
Felix Paul Kühne's avatar
Felix Paul Kühne committed
68
    if (!SYSTEM_RUNS_IOS7_OR_LATER)
69
        returnValue.origin.y = 7.;
70 71 72 73 74
    returnValue.size.width = bounds.size.width - 10.;
    return returnValue;
}

@end