我在使用 iPad 应用程序,我想知道是否可以将范围栏从 UISearchBar 的右侧移动到另一个位置?
我希望将范围栏放在搜索栏下方。那可能吗?
提前致谢。
好的,这是我的解决方案。我将实现我自己的分段控件来创建搜索范围的可能性。
let categories = ["Scope1", "Scope2", "Scope3"]
segmentedControl.addTarget(self, action: "changeScope:", forControlEvents: .ValueChanged)
segmentedControl.frame = CGRectMake(8, 5, 800, 30)
segmentedControl.backgroundColor = UIColor.whiteColor()
segmentedControl.tintColor = UIColor.darkGrayColor()
// add it in a scrollView, because ill got too much categories here. Just if you need that:
scrollView.contentSize = CGSizeMake(segmentedControl.frame.size.width + 16, segmentedControl.frame.size.height-1)
scrollView.showsHorizontalScrollIndicator = false;
// set first category
segmentedControl.selectedSegmentIndex = 0
scrollView.addSubview(segmentedControl)
这是范围栏的功能,当用户切换范围时,您可以随意执行操作:
func changeScope(sender: UISegmentedControl) {
switch(sender.selectedSegmentIndex) {
}
}
就我而言,我从 Web 服务获取了多个 resultArray,并且只显示选定的结果(通常将它们添加到 1 个巨大的结果集中)
希望能对其他人有所帮助。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)