iOSDropDown
iOS 15 update
iOS에서 드롭다운 메뉴를 지원하는 Swift 라이브러리입니다.
비디오 보기:
예제 프로젝트를 실행하려면 리포지토리를 복제하고 먼저 예제 디렉터리에서 pod install
실행하세요.
Swift 패키지 관리자는 Swift 코드 배포를 자동화하는 도구이며 swift
컴파일러에 통합되어 있습니다.
Swift 패키지가 설정되면 iOSDropDown을 종속성으로 추가하는 것은 Package.swift
의 dependencies
값에 추가하는 것만큼 쉽습니다.
dependencies: [
. package ( url : " https://github.com/jriosdev/iOSDropDown.git " , . upToNextMajor ( from : " 0.4.0 " ) )
]
CocoaPod를 사용하세요. iOSDropDown은 CocoaPods를 통해 사용할 수 있습니다. 설치하려면 Podfile에 다음 줄을 추가하기만 하면 됩니다.
pod 'iOSDropDown'
추가하세요.pod install
실행하여 포드를 설치합니다.iOSDropDown.framework
추가import iOSDropDown
추가하세요.카르타고를 사용하세요.
Cartfile
이라는 파일 이름을 만듭니다.github "jriosdev/iOSDropDown"
줄을 추가합니다.carthage update
실행하세요.iOSDropDown.framework
Xcode 프로젝트로 드래그하세요.다음 Swift 파일을 복제하고 프로젝트에 추가하세요.
ViewCOntroller에 UITextField를 추가하고 @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
: 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
등 DropDown에서 사용할 수 있습니다. 1.After Update the pod just do clean your buld folder
Product > Clean Build Folder .
Jishnu Raj T, [email protected]
iOSDropDown은 MIT 라이선스에 따라 사용할 수 있습니다. 자세한 내용은 LICENSE 파일을 참조하세요.