إنها مكتبة Swift لدعم القائمة المنسدلة في iOS
شاهد الفيديو على :
لتشغيل مشروع المثال، قم باستنساخ الريبو، ثم قم بتشغيل pod install
من دليل المثال أولاً.
يعد Swift Package Manager أداة لأتمتة توزيع كود Swift وهو مدمج في المترجم swift
.
بمجرد إعداد حزمة Swift الخاصة بك، فإن إضافة iOSDropDown باعتبارها تبعية تكون بنفس سهولة إضافتها إلى قيمة dependencies
في Package.swift
الخاص بك.
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
في ملفات .swift حيث تريد استخدامهاستخدم قرطاج.
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
: هذا الخيار لإخفاء القائمة عند الضغط على الخيار الأول. القيمة الافتراضية true
selectedRowColor
: لون عنصر الصف المحدد في DropDown، القيمة الافتراضية هي .cyan
rowBackgroundColor
: لون القائمة المنسدلة، القيمة الافتراضية هي .white
listHeight
: الحد الأقصى لارتفاع القائمة. القيمة الافتراضية هي 150
rowHeight
: ارتفاع القائمة في القائمة. القيمة الافتراضية هي 30
selectedIndex
: للاختيار المسبق لأي عنصر في القائمةarrowSize
: حجم السهم. القيمة الافتراضية هي 15
arrowColor
: لون السهم . القيمة الافتراضية هي .black
checkMarkEnabled
: علامة الاختيار ممكّنة لاختيار الصف. القيمة الافتراضية true
textColor
: يمكنك تغيير لون النص المحدد في القائمة المنسدلةsemanticContentAttribute
: السمة الدلالية لـ RTL أو LTRAll 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 .
جيشنو راج تي، [email protected]
iOSDropDown متاح بموجب ترخيص MIT. راجع ملف الترخيص لمزيد من المعلومات.