【发布时间】:2011-09-04 15:24:43
【问题描述】:
我正在尝试让 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?
提前致谢。
【问题讨论】:
标签: iphone animation uiview uislider