InnoSelector
描述
A framework for data selection which has the option for both single and multi-select functionalities. In this, you can also customise the attributes like how the view should present, what will be the title and its colour, whether the table content should have the image or not, colour for the title and subtitle of the table content, bottom theme colour and much more.
示例
要在示例项目中运行,请首先克隆仓库,然后在 InnoSelectorDemo2 目录中运行 pod install
自定义 | 单选/多选 |
---|---|
![]() |
![]() |
推送视图/展示视图 | 全屏 |
---|---|
![]() |
![]() |
导航下拉菜单 | 弹出视图 |
---|---|
![]() |
![]() |
要求
- iOS 8.0+
- Xcode 9.2
使用
初始化
- 对底部面板
let selectorFilter = InnoSelector.bottomSheet()
- 对弹出覆盖
// Your class should implement UIAdaptivePresentationControllerDelegate
class ViewController: UIViewController, UIAdaptivePresentationControllerDelegate{
let selectorFilter = InnoSelector.popOver()
if let whatSender = sender as? UIBarButtonItem{
selectorFilter.popoverPresentationController?.barButtonItem = whatSender
}else{
selectorFilter.popoverPresentationController?.sourceView = sender as? UIView
}
selectorFilter.preferredContentSize = CGSize(width: 300, height: 400
selectorFilter.presentationController?.delegate = self
// Delegate Methods
func adaptivePresentationStyle(for controller: UIPresentationController) -> UIModalPresentationStyle {
return UIModalPresentationStyle.none
}
func adaptivePresentationStyle(for controller: UIPresentationController, traitCollection: UITraitCollection) -> UIModalPresentationStyle {
return UIModalPresentationStyle.none
}
}
- 对导航下拉菜单(仅支持单选)
let selectorFilter = InnoSelector.navigationDropDown()
传递数据
目前我们支持[字符串]和[自定义对象]
var data: [InnoData] = []
var data2: [InnoData] = []
var data3:[String] = []
var data4:[String] = []
var multiselecr: Bool = true
data = [CustomDataObject(image: <#T##UIImage?#>, primaryText: <#T##String#>, subText: <#T##String?#>)]
data3 = ["Gopi", "Asmita", "Jassi", "Manoj", "Dhiraj", "Suraj"]
对[自定义数据]
selectorFilter.setContent(dataSource: data, selectedValues: data2, isMultiselect: multiselecr, minSelection: 1, maxSelection: 10)
对[字符串]
selectorFilter.setContent(dataSource: data3, selectedValues: data4, isMultiselect: multiselecr, minSelection: 1, maxSelection: 10)
- 注意:对于导航下拉菜单,“isMultiselect”应设置为false。
展示视图
- 对底部面板
var pushView: Bool = false
if pushView {
selectorFilter.push(viewController: self, innoSelector: selectorFilter)
}else{
selectorFilter.presentIn(viewController: self)
}
- 对弹出覆盖
present(selectorFilter, animated: true, completion: nil)
- 对导航下拉菜单
let selectorFilter = InnoSelector.navigationDropDown()
selectorFilter.present()
完成处理程序
selectorFilter.completionHandler = { event, selectedValues in
switch event {
case .didApply:
if let selectedData = selectedValues as? [InnoData]{
self.data2 = selectedData
}else{
self.data4 = selectedValues as! [String]
}
print(selectedValues.count)
case .didCancel:
print("Cancel")
}
}
自定义
针对底部面板
- 设置全屏
selectorFilter.setFullScreen = true
- 更改布局高度
selectorFilter.selectorViewHeight = 300.0
- 设置标题
selectorFilter.setTitle(title: "titleString", color: titleTextColor)
- 设置按钮主题
selectorFilter.setButtonThemeColor(color: UIColor.black)
- 设置内容主题
selectorFilter.setContentTextColor(Title: tablePriText, subTitle: tableSubText)
- 隐藏顶部栏
selectorFilter.hideTopBar = true
- 设置字体
selectorFilter.setTextLabelFont(name: "Avenir", size: 15)
selectorFilter.setDetailTextLabelFont(name: "Avenir", size: 15)
针对弹出菜单
- 设置按钮主题
selectorFilter.setButtonThemeColor(color: UIColor.black)
- 设置内容主题
selectorFilter.setContentTextColor(Title: tablePriText, subTitle: tableSubText)
针对导航下拉菜单
- 设置内容主题
selectorFilter.setContentTextColor(Title: tablePriText, subTitle: tableSubText)
- 设置表格高度
selectorFilter.tableHeight = 250
安装
InnoSelector 通过 CocoaPods 提供。要安装,只需将以下行添加到您的 Podfile 中
pod 'InnoSelector'
作者
Gopinath A, [email protected]
许可证
InnoSelector 按照MIT许可证提供。更多信息请参阅 LICENSE 文件。