IOS下拉标签选择器

下拉标签选择器
DropDownMenuView
简单的下拉标签选择器,提供选中和取消选中,单链表和双链表组合,支持代理配置图片,可以自定义配置

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

先看下效果IOS下拉标签选择器_第1张图片
:

效果图
实现思路
通过代理设置每列样式,数据原,代理数据传递给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)

}

你可能感兴趣的:(ios,swift,xcode)