我试图让UISliders在不能使用时动画变灰。带alpha的UISlider动画
这里是我的UISlider子类代码:
- (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];
}
}
如果滑块的符号属性设置为@“”或@“e_none”,将是灰色滑块和原因它不是互动的。但是在某些情况下,行[self setValue:newValue animated:YES]
似乎“取消”了setAlpha动画。
有没有什么办法可以同时设置滑块的值并使用UIView动画改变它的alpha值?
在此先感谢。
嗯。这不起作用,似乎每次更改滑块的值都会自动将alpha更改为1。 – chmod
当你先设定值和alpha后会发生什么......? – Mohammad
滑块的值将更改,但alpha将保持为1。 – chmod