下拉标签选择器
DropDownMenuView
简略的下拉标签选择器,提供选中和勾销选中,单链表和双链表组合,反对代理配置图片,能够自定义配置
仓库地址:https://github.com/gu0315/Dro...
先看下成果
:
效果图
实现思路
通过代理设置每列款式,数据原,代理数据传递给tableView,collectionView刷新数据,通过每列款式更改款式
可反对的配置项
final class DMConfiguration {
`///Cell的高度,默认44varcellHeight:CGFloat=44;///内容的高度var contentViewHeight:CGFloat = 300;///是否自适应高度,默认为Falsevar isAdaptiveHeight:Bool = false///题目色彩var textColor:UIColor = UIColor.darkGray// 当有二级列表时,点击row 是否调用点击代理办法var isRefreshWhenHaveRightItem:Bool = false///题目选中色彩var highlightedTextColor:UIColor = UIColor.orange///有多少分区varnumOfMenu:Int=0;///字体大小varfontSize:CGFloat=15///题目的色彩vartitleColor:UIColor= .darkGray///是否显示分割线色彩.默认显示var isShowSeparator:Bool = true///分割线占比高度var separatorHeighPercent:CGFloat = 0.5;///分割线色彩var separatorColor:UIColor = .lightGray///指示器图标地位,默认文字右侧var indicatorAlignType:IndicatorAlignType = .IndicatorAlignCloseToTitle///背景色彩varmaskColor:UIColor=UIColor.init(white:0.4, alpha:0.2)///切换条件时是否更改menu titlevar isRemainMenuTitle:Bool = true///cell文字大小varcellTitleFont=UIFont.systemFont(ofSize:14)init() { self.defaultValue()}func defaultValue() {}` * 1* 2* 3* 4* 5* 6* 7* 8* 9* 10* 11* 12* 13* 14* 15* 16* 17* 18* 19* 20* 21* 22* 23* 24* 25* 26* 27* 28* 29* 30* 31* 32* 33* 34* 35* 36* 37* 38* 39* 40* 41* 42* 43* 44* 45* 46* 47* 48* 49* 50* 51* 52* 53* 54* 55* 56* 57* 58* 59* 60* 61* 62* 63* 64* 65* 66* 67* 68* 69* 70* 71* 72* 73
}
代理回调
@objc public protocol DMenuViewDataSource: NSObjectProtocol {
`///返回有多少列@objc func numberOfColumnsInMenu(menu:DropDownMenuView) -> Int///左侧TableView每列有多少条数据@objcfuncnumberOfRowsInColumn(menu:DropDownMenuView, column:Int) ->Int///左侧TableView对应的每行的数据@objcfunctitleForRowAtIndexPath(menu:DropDownMenuView, column:Int, row:Int) ->DMRowData///右侧CollectionView或者TableView有多少条数据@objcoptionalfuncnumberOfRightItemInMenu(menu:DropDownMenuView, column:Int, row:Int) ->Int///右侧CollectionView或者TableView对应的每行的数据@objcoptionalfunctitleForRightRowAtIndexPath(menu:DropDownMenuView, column:Int, leftRow:Int, rightRow:Int) ->DMRowData///返回每列的类型,默认只有一个tableView@objc optional func columnTypeInMenu(menu:DropDownMenuView, column: Int) -> DMenuViewColumnType///右边tableView所占比例@objcoptionalfuncleftTableViewWidthScale(menu:DropDownMenuView, column:Int) ->CGFloat` * 1* 2* 3* 4* 5* 6* 7* 8* 9* 10* 11* 12* 13* 14* 15* 16* 17* 18* 19* 20* 21* 22* 23* 24* 25* 26* 27* 28* 29* 30* 31
}
@objc public protocol DMenuViewDelegate: NSObjectProtocol {
`///点击回掉@objcoptionalfuncdidSelectRowAtIndexPath(menu:DropDownMenuView, column:Int, leftRow:Int, rightRow:Int);` * 1* 2* 3* 4* 5
///标签抉择显示状态
@objcoptionalfuncmenuIsShow(menu:DropDownMenuView, isShow:Bool)
}