关于ios:IOS下拉标签选择器

2次阅读

共计 2399 个字符,预计需要花费 6 分钟才能阅读完成。

下拉标签选择器
DropDownMenuView
简略的下拉标签选择器,提供选中和勾销选中, 单链表和双链表组合, 反对代理配置图片, 能够自定义配置

仓库地址:https://github.com/gu0315/Dro…

先看下成果
:

效果图
实现思路
通过代理设置每列款式, 数据原, 代理数据传递给 tableView,collectionView 刷新数据, 通过每列款式更改款式

可反对的配置项

final class DMConfiguration {

`///Cell 的高度, 默认 44

varcellHeight:CGFloat=44;

/// 内容的高度

var contentViewHeight:CGFloat = 300;

/// 是否自适应高度, 默认为 False

var 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 title

var 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)

}

正文完
 0