@@ -36,35 +36,47 @@ @implementation MDCSlider {
36
36
- (instancetype )initWithFrame : (CGRect)frame {
37
37
self = [super initWithFrame: frame];
38
38
if (self) {
39
- CGRect trackFrame = CGRectInset (frame, 8 .f , 0 .f );
40
-
41
- _thumbTrack = [[MDCThumbTrack alloc ] initWithFrame: trackFrame onTintColor: [[self class ] defaultColor ]];
42
- _thumbTrack.delegate = self;
43
- _thumbTrack.disabledTrackHasThumbGaps = YES ;
44
- _thumbTrack.trackEndsAreInset = YES ;
45
- _thumbTrack.thumbRadius = kSliderThumbRadius ;
46
- _thumbTrack.thumbMaxRippleRadius = kSliderThumbMaxRippleRadius ;
47
- _thumbTrack.trackOffColor = [[self class ] defaultTrackOffColor ];
48
- [_thumbTrack addTarget: self
49
- action: @selector (thumbTrackValueChanged: )
50
- forControlEvents: UIControlEventValueChanged];
51
- [_thumbTrack addTarget: self
52
- action: @selector (thumbTrackTouchDown: )
53
- forControlEvents: UIControlEventTouchDown];
54
- [_thumbTrack addTarget: self
55
- action: @selector (thumbTrackTouchUpInside: )
56
- forControlEvents: UIControlEventTouchUpInside];
57
- [_thumbTrack addTarget: self
58
- action: @selector (thumbTrackTouchUpOutside: )
59
- forControlEvents: UIControlEventTouchUpOutside];
60
- [_thumbTrack addTarget: self
61
- action: @selector (thumbTrackTouchCanceled: )
62
- forControlEvents: UIControlEventTouchCancel];
63
- [self addSubview: _thumbTrack];
39
+ [self commonInit ];
64
40
}
65
41
return self;
66
42
}
67
43
44
+ - (instancetype )initWithCoder : (NSCoder *)aDecoder {
45
+ self = [super initWithCoder: aDecoder];
46
+ if (self) {
47
+ [self commonInit ];
48
+ }
49
+ return self;
50
+ }
51
+
52
+ - (void )commonInit {
53
+ CGRect trackFrame = CGRectInset (self.frame , 8 .f , 0 .f );
54
+
55
+ _thumbTrack = [[MDCThumbTrack alloc ] initWithFrame: trackFrame onTintColor: [[self class ] defaultColor ]];
56
+ _thumbTrack.delegate = self;
57
+ _thumbTrack.disabledTrackHasThumbGaps = YES ;
58
+ _thumbTrack.trackEndsAreInset = YES ;
59
+ _thumbTrack.thumbRadius = kSliderThumbRadius ;
60
+ _thumbTrack.thumbMaxRippleRadius = kSliderThumbMaxRippleRadius ;
61
+ _thumbTrack.trackOffColor = [[self class ] defaultTrackOffColor ];
62
+ [_thumbTrack addTarget: self
63
+ action: @selector (thumbTrackValueChanged: )
64
+ forControlEvents: UIControlEventValueChanged];
65
+ [_thumbTrack addTarget: self
66
+ action: @selector (thumbTrackTouchDown: )
67
+ forControlEvents: UIControlEventTouchDown];
68
+ [_thumbTrack addTarget: self
69
+ action: @selector (thumbTrackTouchUpInside: )
70
+ forControlEvents: UIControlEventTouchUpInside];
71
+ [_thumbTrack addTarget: self
72
+ action: @selector (thumbTrackTouchUpOutside: )
73
+ forControlEvents: UIControlEventTouchUpOutside];
74
+ [_thumbTrack addTarget: self
75
+ action: @selector (thumbTrackTouchCanceled: )
76
+ forControlEvents: UIControlEventTouchCancel];
77
+ [self addSubview: _thumbTrack];
78
+ }
79
+
68
80
#pragma mark - ThumbTrack passthrough methods
69
81
70
82
- (void )setTrackBackgroundColor : (UIColor *)trackBackgroundColor {
0 commit comments