-
Notifications
You must be signed in to change notification settings - Fork 235
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
Slider not changing between colors when changing value #20
Comments
Here is the code I've just tried in a UITableViewCell subclass: - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
self.recordPercentageSlider = [ASValueTrackingSlider new];
self.recordPercentageSlider.delegate = self;
self.recordPercentageSlider.frame = CGRectMake(20.0, 45.0, CGRectGetWidth(self.frame) - 2.0 * 20.0, 31.0);
self.recordPercentageSlider.font = [UIFont fontWithName:@"AvenirNext-Medium" size:15.0];
self.recordPercentageSlider.tintColor = [UIColor redColor];
self.recordPercentageSlider.autoAdjustTrackColor = NO;
[self.recordPercentageSlider addTarget:self action:@selector(recordPercentageValueChanged) forControlEvents:UIControlEventValueChanged];
[self.contentView addSubview:self.recordPercentageSlider];
NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
[numberFormatter setNumberStyle:NSNumberFormatterPercentStyle];
[self.recordPercentageSlider setNumberFormatter:numberFormatter];
self.recordPercentageSlider.popUpViewAnimatedColors = @[[UIColor orangeColor], [UIColor purpleColor]];
}
return self;
} The colors animated as expected. I also tried setting up the slider in a table cell in the storyboard and setting the animated colors in Could you offer anymore info to help me track down the problem. Could you also check the colors you set to make sure they are what you expected in the following line: self.recordPercentageSlider.popUpViewAnimatedColors = @[[UIColor carbonColorWithAlpha:ZTAlphaLevelFull], [UIColor autumnColorWithAlpha:ZTAlphaLevelFull]]; |
Just copies the code snippet you posted, and it worked in one situation and not in the other. Nothing elaborate about the colors, only these: Any other info you need, just tell me and thanks again for your time |
Hi @aj1310, Does the animation work initially then fail to update after some action, or does it never work in this instance? |
Hi, I'm not sure if this is 100% related, but I've just come here to log an issue about animation colour not working correctly - depending on the min, max values and the stop positions. here's my code
This results in incorrect values being calculated in ASValueTrackingSlider keyTimesFromSliderPositions:, in this case instead of returning 3 values evenly spaced from 0.0 to 1.0 I get
This results in the green colour never being shown when the slider is at 5 - it's still yellow. If I do the same but adjust the maximumValue to 10.0 the colors work more as expected, (but still not quite if you look at the keyTimes output).
results in keyTimes of
Happy to open new Issue, but thought it might be of use here. |
Hi @DisobedientMedia, Cheers, |
Great, thanks. I tried the slider.popUpViewAnimatedColors = @[color1,color2,color3], but as you say, it didn't work as expected. |
Hi @DisobedientMedia, Cheers, |
Thanks Al, works as expected now. Much appreciated. |
Hi @aj1310, All the best, |
Hi Robin, Please pass on my greetings to the glorious north, |
Hi @alskipp I'm using ASValueTrackingSlider in a UITableViewCell with a a few values being passed for the animation, when the initial value of the slider is 0 it works correctly however if I set a different initial value the popupview and slider still start from the first color passed in and as a result don't reach the last color in the animation. For example I'm setting 5 colors like the following [self.accuracySlider setPopUpViewAnimatedColors:@[
[UIColor redColor],
[UIColor orangeColor],
[UIColor purpleColor],
[UIColor blueColor],
[UIColor greenColor]]]; And I'm then setting the value of the slider (in self.accuracySlider.value = 10.0; In this case the popupview and slider never reach the green color. If however I defer setting the sliders value it works correctly dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0 * NSEC_PER_SEC)),
dispatch_get_main_queue(), ^{
self.accuracySlider.value = 10.0;
}); |
Hi @Jack-s I've been unable to reproduce the issue, which makes it very difficult to solve the problem you've been experiencing. Would it be at all possible to post a gist/send me a small example that demonstrates the issue? I'm very keen to give this bug a good squashing, but it's eluding me! All the best, |
@alskipp I modified the example to reproduce the issue, here's a link to the project |
Hi @Jack-s , Al |
Hmmm, I'm now seeing this issue occur quite frequently on Xcode 6 (beta 5). In Xcode 5, it only seemed to occur in a few edge cases. Will investigate further. |
These issues seem to have been resolved when using the latest Xcode release (6.3). I'll close the issue for now on the assumption that all is well crossed fingers. |
self.recordPercentageSlider = [ASValueTrackingSlider new];
self.recordPercentageSlider.delegate = self;
self.recordPercentageSlider.frame = CGRectMake(20.0, 45.0, CGRectGetWidth(self.frame) - 2.0 * 20.0, 31.0);
//self.recordPercentageSlider.value = 1.0;
self.recordPercentageSlider.font = [UIFont fontWithName:@"AvenirNext-Medium" size:15.0];
self.recordPercentageSlider.tintColor = [UIColor autumnColorWithAlpha:ZTAlphaLevelFull];
[self.recordPercentageSlider addTarget:self action:@selector(recordPercentageValueChanged) forControlEvents:UIControlEventValueChanged];
[self.contentView addSubview:self.recordPercentageSlider];
NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
[numberFormatter setNumberStyle:NSNumberFormatterPercentStyle];
[self.recordPercentageSlider setNumberFormatter:numberFormatter];
self.recordPercentageSlider.popUpViewAnimatedColors = @[[UIColor carbonColorWithAlpha:ZTAlphaLevelFull], [UIColor autumnColorWithAlpha:ZTAlphaLevelFull]];
This is the code I used for inserting the slider but will only display the first color in the array. I used these same lines for two different part of a project, both in table's cells, in which the animation did trigger while the other didn't.
The text was updated successfully, but these errors were encountered: