iOSDropDown
iOS 15 update
iOSのドロップダウンメニューをサポートするSwiftライブラリです
ビデオを見る:
サンプル プロジェクトを実行するには、リポジトリのクローンを作成し、最初に Example ディレクトリからpod install
実行します。
Swift パッケージ マネージャーは、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
実行してポッドをインストールします。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
: DropDown で有効または無効にすることができます。デフォルト値はtrue
です。hideOptionsWhenSelect
: オプション 1 項目をクリックしたときにリストを非表示にするオプションです。デフォルト値はtrue
ですselectedRowColor
: ドロップダウンで選択されている行項目の色 デフォルト値は.cyan
rowBackgroundColor
: ドロップダウンの色 デフォルト値は.white
ですlistHeight
: リストの最大の高さ。デフォルト値は150
ですrowHeight
: リスト内のリストの高さ。デフォルト値は30
ですselectedIndex
: リスト内の項目の事前選択用arrowSize
: 矢印のサイズ。デフォルト値は15
ですarrowColor
: 矢印の色。デフォルト値は.black
ですcheckMarkEnabled
: 行の選択に対して有効なチェックマーク。デフォルト値はtrue
ですtextColor
: ドロップダウンで選択したテキストの色を変更できますsemanticContentAttribute
: RTL または LTR のセマンティック属性alignment
、 font
、 textColor
、 semanticContentAttribute
など、 All Other TextField Properties are available with DropDown
。 1.After Update the pod just do clean your buld folder
Product > Clean Build Folder .
Jishnu Raj T、[email protected]
iOSDropDown は MIT ライセンスに基づいて利用できます。詳細については、LICENSE ファイルを参照してください。