Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue fix 45 #92

Merged
merged 2 commits into from
Feb 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Example/RangeSliderDemo/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ - (void)viewDidLoad {
self.rangeSlider.maxValue = 200;
self.rangeSlider.selectedMinimum = 50;
self.rangeSlider.selectedMaximum = 150;

self.rangeSlider.shadowRadius = 2;
self.rangeSlider.shadowOpacity = 0.75;

[self.rangeSlider addTarget:self action:@selector(logControlEvent:) forControlEvents:UIControlEventValueChanged];

//currency range slider
Expand Down Expand Up @@ -58,6 +62,10 @@ - (void)viewDidLoad {
NSNumberFormatter *customFormatter = [[NSNumberFormatter alloc] init];
customFormatter.positiveSuffix = @"B";
self.rangeSliderCustom.numberFormatterOverride = customFormatter;

self.rangeSliderCustom.shadowRadius = 3;
self.rangeSliderCustom.shadowOpacity = 0.5;

}

- (void)didReceiveMemoryWarning {
Expand Down
11 changes: 11 additions & 0 deletions Pod/Classes/TTRangeSlider.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,4 +193,15 @@ typedef NS_ENUM(NSInteger, LabelPosition) {
*/
@property (nonatomic, assign) LabelPosition labelPosition;

/**
*Set radius of the shadow for handle. Also used for setting shadow offset value
*/

@property (nonatomic, assign) IBInspectable CGFloat shadowRadius;

/**
*Set the opacity of the shadow for handle
*/
@property (nonatomic, assign) IBInspectable float shadowOpacity;

@end
51 changes: 50 additions & 1 deletion Pod/Classes/TTRangeSlider.m
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ - (BOOL)beginTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event {

- (void)refresh {

if (self.enableStep && self.step>=0.0f){
if (self.enableStep && self.step>0.0f){
_selectedMinimum = roundf(self.selectedMinimum/self.step)*self.step;
_selectedMaximum = roundf(self.selectedMaximum/self.step)*self.step;
}
Expand Down Expand Up @@ -692,6 +692,55 @@ -(void)setBarSidePadding:(CGFloat)barSidePadding {
[self updateLabelPositions];
}

- (void)setShadowRadius:(CGFloat)shadowRadius {
_shadowRadius = shadowRadius;
_shadowOpacity = 1.0;

[self.leftHandle removeFromSuperlayer];

self.leftHandle.shadowOffset = CGSizeMake(0.0, self.shadowRadius);
self.leftHandle.shadowRadius = self.shadowRadius;
self.leftHandle.shadowColor = self.tintColor.CGColor;

[self.layer addSublayer:self.rightHandle];

self.rightHandle.shadowOffset = CGSizeMake(0.0, _shadowRadius);
self.rightHandle.shadowRadius = _shadowRadius;
self.rightHandle.shadowColor = self.tintColor.CGColor;

[self.layer addSublayer:self.rightHandle];
}

- (void)setShadowOpacity:(float)shadowOpacity {
_shadowOpacity = shadowOpacity;

[self.leftHandle removeFromSuperlayer];

self.leftHandle.shadowOffset = CGSizeMake(0.0, self.shadowRadius);
self.leftHandle.shadowOpacity = self.shadowOpacity;
self.leftHandle.shadowColor = self.tintColor.CGColor;

[self.layer addSublayer:self.rightHandle];

self.rightHandle.shadowOffset = CGSizeMake(0.0, _shadowRadius);
self.rightHandle.shadowOpacity = _shadowOpacity;
self.rightHandle.shadowColor = self.tintColor.CGColor;

[self.layer addSublayer:self.rightHandle];
}

- (void)setEnableStep:(BOOL)enableStep {
_enableStep = enableStep;

[self refresh];
}

- (void)setStep:(float)step {
_step = step;

[self refresh];
}

#pragma mark - UIAccessibility

- (BOOL)isAccessibilityElement
Expand Down