VLCSlider.m 2.75 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
    returnValue.size.width = bounds.size.width - 10.;
    return returnValue;
}

@end


@implementation VLCSlider

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

56 57
- (void)awakeFromNib
{
58
    if (SYSTEM_RUNS_IOS7_OR_LATER)
59 60 61 62 63 64 65 66
        [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];
    }
67 68 69 70 71
}

- (CGRect)trackRectForBounds:(CGRect)bounds
{
    CGRect returnValue = [super trackRectForBounds:bounds];
72 73 74
    if (SYSTEM_RUNS_IOS7_OR_LATER)
        return returnValue;

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

@end