I'm trying to make UISliders that animate to be greyed out when they cannot be used.
Here is the code in my UISlider subclass:
- (void)setSymbol:(NSString *)s {
symbol = s;
float newValue = [[S76PresetManager sharedManager] getValueForKey:symbol];
[self setValue:newValue animated:YES];
if (symbol == @"" || symbol == @"e_none") {
// gray out the slider
[self setUserInteractionEnabled:NO];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
[self setAlpha:0.5];
[UIView commitAnimations];
} else {
// reactivate the slider
[self setUserInteractionEnabled:YES];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
[self setAlpha:1.0];
[UIView commitAnimations];
}
}
If the slider's symbol property is set to @"" or @"e_none", it will gray out the slider and cause it to not be interactive. However the line [self setValue:newValue animated:YES]
seems to "cancel out" the setAlpha animation in some cases.
Is there any way I can simultaneously set the value of the slider and change its alpha using UIView animations?
Thanks in advance.