iOSDropDown 0.4.0

iOSDropDown 0.4.0

JR 维护。




iOS DropDown

Version Cocoapods Swift 4.0 License Platform Star

支持搜索功能的iOS下拉菜单

这是一个支持iOS下拉菜单的Swift库

观看视频:

支持搜索并返回正确索引

定制

hideOptionWhenSelect = false

示例

要运行示例项目,请克隆仓库,然后先从示例目录运行 pod install

功能

  1. 简单的UITextField扩展,使用简单,我们可以访问UITextField的所有属性
  2. 可以启用或禁用下拉搜索
  3. 可以更改列表的背景颜色和选定颜色
  4. 可以更改列表的最大高度和每行的高度

安装

CocoaPods

使用CocoaPods。iOSDropDown通过CocoaPods提供。要安装它,请简单地将以下行添加到您的Podfile中

  1. pod 'iOSDropDown'添加到您的Podfile中。
  2. 通过运行pod install安装pod。
  3. 在构建阶段 > 链接二进制库中添加iOSDropDown.framework
  4. 在您想要使用它的.swift文件中添加import iOSDropDown

Carthage

使用Carthage

  1. 创建一个名为Cartfile的文件。
  2. 添加行github "jriosdev/iOSDropDown"
  3. 运行carthage update
  4. 将构建好的iOSDropDown.framework拖到您的Xcode项目中。

手册

只需克隆并添加以下Swift文件到您的项目中

  • iOSDropDown.swift

基本用法

Storyboard方法

只需将UITextField添加到您的ViewController中,并连接至@IBOutlet - DropDown类

@IBOutlet weak var dropDown : DropDown!

// The list of array to display. Can be changed dynamically
dropDown.optionArray = ["Option 1", "Option 2", "Option 3"]
//Its Id Values and its optional
dropDown.optionIds = [1,23,54,22] 

// Image Array its optional
dropDown.ImageArray = [👩🏻‍🦳,🙊,🥞]
// The the Closure returns Selected Index and String 
dropDown.didSelect{(selectedText , index ,id) in
self.valueLabel.text = "Selected String: \(selectedText) \n index: \(index)"
}

代码方法

let  dropDown = DropDown(frame: CGRect(x: 110, y: 140, width: 200, height: 30)) // set frame

// The list of array to display. Can be changed dynamically
dropDown.optionArray = ["Option 1", "Option 2", "Option 3"]
// Its Id Values and its optional
dropDown.optionIds = [1,23,54,22] 
// Image Array its optional
dropDown.ImageArray = [👩🏻‍🦳,🙊,🥞]

// The the Closure returns Selected Index and String 
dropDown.didSelect{(selectedText , index ,id) in
self.valueLabel.text = "Selected String: \(selectedText) \n index: \(index)"
    }
}

其他选项

动作

 dropDown.showList()  // To show the Drop Down Menu
 dropDown.hideList() // To hide the Drop Down Menu

闭包

 listWillAppear() {
  //You can Do anything when iOS DropDown willAppear 
 }

listDidAppear() {
    //You can Do anything when iOS DropDown listDidAppear
}

listWillDisappear() {
  //You can Do anything when iOS DropDown listWillDisappear 
}

 listDidDisappear() {
  //You can Do anything when iOS DropDown listDidDisappear
}

自定义iOSDropDown🖌

您可以自定义以下下拉菜单属性:

  • isSearchEnabled : 可以开启或关闭在下拉菜单中。默认值是 true
  • hideOptionsWhenSelect : 选择某一选项时,隐藏列表。默认值是 true
  • selectedRowColor:下拉列表中选中行的颜色。默认值为.cyan
  • rowBackgroundColor:下拉列表的背景颜色。默认值为.white
  • listHeight:列表的最大高度。默认值是150
  • rowHeight:列表中行的高度。默认值是30
  • selectedIndex:用于提前选择列表中的任何一个项目
  • arrowSize:箭头的大小。默认值是15
  • arrowColor:箭头的颜色。默认值是.black
  • checkMarkEnabled:用于选择行的复选标记启用。默认值是true
  • textColor:可以更改下拉列表的选中文本颜色
  • semanticContentAttribute:用于RTL或LTR的语义属性
  • 除了TextField属性外,所有其他属性都可以在下拉列表中使用,例如alignmentfonttextColorsemanticContentAttribute

注意

1.After Update the pod just do clean your buld folder 
      Product > Clean Build Folder . 

作者

如果喜欢我的项目,请在GitHub上给我一个STAR

如果这个项目帮助您减少了开发时间,您能提供一杯咖啡吗:)

paypal

Jishnu Raj T,[email protected] 联系

许可协议

iOSDropDown遵循MIT许可协议。有关更多信息,请参阅LICENSE文件。