SASelectionView
一种轻量级的单选视图,从屏幕底部滑入。
- 易于使用
- 分节行
- 自动调整选择视图高度
- 根据项目数量自动显示搜索栏。您也可以手动隐藏/显示搜索栏
- 手势控制,向下拖动以关闭
显示各州(部分)的市(行)的列表
Requirements
SASelectionView 支持iOS 9及以上版本。它依赖于以下 Apple 框架,这些框架通常已包含在大多数 Xcode 模板中
- Foundation
- UIKit
Installation
CocoaPods
您可以通过将 SASelectionView 添加到 Podfile 使用 CocoaPods 进行安装
platform :ios, '9.0'
use_frameworks!
pod 'SASelectionView'
手动
- 下载并解压zip文件。
- 将源文件夹拖放到您的项目中。
- 完成!
示例
import UIKit
import SASelectionView
class ViewController: UIViewController {
@IBOutlet weak var selectedOptionLabel: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
@IBAction func didTapButton(_ sender: Any) {
var sections = [SectionItem]()
sections.append(SectionItem(title: "Texas", options: ["Dallas", "Houston", "Austin", "San Antonio"]))
sections.append(SectionItem(title: "California", options: ["Los Angeles", "San Francisco", "Sacramento", "San Diago"]))
sections.append(SectionItem(title: "New York", options: ["New York City", "Albany", "Buffalo"]))
sections.append(SectionItem(title: "Florida", options: ["Miami", "Orlando", "Jacksonville", "Key West"], disabledIndices: [3:[1,3]]))
SASelectionView.show(title: "Locations", sections: sections, showSearchBar: true, emptySearchRowTitle: "Item not found. Add this ...", emptyRowHandler: { (notFoundText) in
print("Not found result: \(notFoundText)")
self.selectedOptionLabel.text = notFoundText
}) { (section, row, value) in
self.selectedOptionLabel.text = "\(value), \(sections[section].title ?? "")"
}
}
}
贡献
如果您有功能请求或错误报告,请随时通过发送拉取请求或创建问题来帮帮忙。
许可证
本代码是按照MIT许可证的条款和条件分发的。