iOSDropDown
iOS 15 update
這是一個支援 iOS 中下拉選單的 Swift 函式庫
觀看影片:
若要執行範例項目,請複製儲存庫,然後先從範例目錄執行pod install
。
Swift Package Manager 是一個用於自動分發 Swift 程式碼的工具,並整合到swift
編譯器中。
設定好 Swift 套件後,將 iOSDropDown 新增為相依性就像將其新增至Package.swift
的dependencies
值一樣簡單。
dependencies: [
. package ( url : " https://github.com/jriosdev/iOSDropDown.git " , . upToNextMajor ( from : " 0.4.0 " ) )
]
使用 CocoaPods。 iOSDropDown 可透過 CocoaPods 取得。要安裝它,只需將以下行新增至您的 Podfile 中:
pod 'iOSDropDown'
加入您的Podfile 。pod install
安裝 pod。iOSDropDown.framework
import iOSDropDown
使用迦太基。
Cartfile
。github "jriosdev/iOSDropDown"
。carthage update
。iOSDropDown.framework
拖曳到您的 Xcode 專案中。只需克隆以下 Swift 檔案並將其添加到您的專案中:
只需將 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
}
自訂過濾功能
// overridable function for filter action
func searchFilter ( text : String , searchText : String ) -> Bool {
// you can add custom filter fuctions as your need, like other than english ..etc
}
您可以自訂下拉清單的這些屬性:
isSearchEnabled
:您true
在 DropDown 上啟用或停用。hideOptionsWhenSelect
:此選項可在按一下選項一項時隱藏清單。預設值為true
selectedRowColor
: DropDown 中選定行項目的顏色預設值為.cyan
rowBackgroundColor
: DropDown 的顏色預設值為.white
listHeight
:清單的最大高度。預設值為150
rowHeight
:清單中清單的高度。預設值為30
selectedIndex
:用於預先選擇清單中的任何項目arrowSize
:箭頭的大小。預設值為15
arrowColor
:箭頭的顏色。預設值為.black
checkMarkEnabled
:勾選「標記已啟用」以選擇行。預設值為true
textColor
:您可以變更 DropDown 選取的文字顏色semanticContentAttribute
:RTL或LTR的語意屬性All Other TextField Properties are available with DropDown
例如alignment
、 font
、 textColor
、 semanticContentAttribute
...等 1.After Update the pod just do clean your buld folder
Product > Clean Build Folder .
Jishnu Raj T,[email protected]
iOSDropDown 在 MIT 許可下可用。有關詳細信息,請參閱許可證文件。