我想创建一个具有三个位置的自定义UISwtich。可能吗?Triple UISwitch
4
A
回答
10
您应该使用UISegmentedControl
如果你想有一个标准的UI-Element或射程为2配置UISlider
:
slider.minimumValue = 0;
slider.maximumValue = 2;
slider.continuous = NO;
,然后设置minimumValueImage
,maximumTrackImage
和thumbImage
使用适当的图像。
4
不使用内置的UISwitch。你需要推出自己的。
4
为什么不使用UISegmentedControl?
0
使用UISlider是一种很好的方法。但你还想调整你的UISlider的机制,使其更像UISwitch。也就是说,当你不完全改变它的位置时,它应该反弹回原位。
这里是我落得这样做(使用FelixLam的答案的一部分):
UISlider *slider = [[UISlider alloc] initWithFrame:CGRectMake(screenRect.size.width*0.5-width/2, screenRect.size.height*0.95-height, width, height)];
slider.minimumValue = 0;
slider.maximumValue = 2;
slider.continuous = NO;
slider.value = 1;
[slider addTarget:self action:@selector(sliderAction:) forControlEvents:UIControlEventValueChanged];
随着...
- (void)sliderAction:(UISlider *)slider {
float origValue = slider.value;
[UIView beginAnimations:nil context:NULL];
if (slider.value<1.9 && slider.value>0.1) slider.value=1;
else if (slider.value>1.9) slider.value=2;
else slider.value=0;
[UIView setAnimationDuration:0.2*fabs(slider.value-origValue)];
[UIView commitAnimations];
}
相关问题
- 1. Java ME Triple Store
- 2. ruby triple equal
- 3. CUDA中的Triple For循环
- 4. Java n-triple RDF解析
- 5. 打印Highest Pythagorean Triple - C
- 6. 与UISwitch
- 7. iPhone UISwitch反应与另一个UISwitch
- 8. UISwitch返回NULL?
- 9. UISwitch控制
- 10. 自定义UISwitch?
- 11. uiswitch和UITableView的
- 12. UISwitch状态viewdidload
- 13. UISwitch和UITableViewCell iOS4
- 14. 多UISwitch项目
- 15. UITableView内的UISwitch
- 16. UISwitch not deococating
- 17. UITableViewCell中的UISwitch
- 18. UISwitch自定义
- 19. UISwitch定制
- 20. UISwitch定制?
- 21. Triple'菱形'图像拆分CSS
- 22. 如何禁用UISwitch?
- 23. UISwitch设置状态
- 24. UISwitch操作方法
- 25. Xamarin.iOS UISwitch tap问题
- 26. 重新创建UISwitch
- 27. UISwitch和本地化
- 28. 试图改变UISwitch
- 29. 切换两个UISwitch
- 30. UISwitch粘在UITableViewCell中
使用一个UISegmentedControl是一个伟大的想法! UISlider的问题在于你必须触摸球才能改变价值,体验并不好。我想我会用UISegmentedControl,谢谢! – arielcamus 2010-01-28 10:55:20