├── LICENCE ├── README.md ├── YBTextPicker.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── xcuserdata │ ├── krishna.xcuserdatad │ ├── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ │ └── xcschememanagement.plist │ ├── yahya.xcuserdatad │ ├── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ │ └── xcschememanagement.plist │ └── yahyabagia.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ └── xcschememanagement.plist └── YBTextPicker ├── AppDelegate.swift ├── Assets.xcassets ├── AppIcon.appiconset │ ├── Contents.json │ ├── Icon-App-20x20@1x.png │ ├── Icon-App-20x20@2x-1.png │ ├── Icon-App-20x20@2x.png │ ├── Icon-App-20x20@3x.png │ ├── Icon-App-29x29@1x.png │ ├── Icon-App-29x29@2x-1.png │ ├── Icon-App-29x29@2x.png │ ├── Icon-App-29x29@3x.png │ ├── Icon-App-40x40@1x.png │ ├── Icon-App-40x40@2x-1.png │ ├── Icon-App-40x40@2x.png │ ├── Icon-App-40x40@3x.png │ ├── Icon-App-60x60@2x.png │ ├── Icon-App-60x60@3x.png │ ├── Icon-App-76x76@1x.png │ ├── Icon-App-76x76@2x.png │ ├── Icon-App-83.5x83.5@2x.png │ └── ItunesArtwork@2x.png └── Contents.json ├── Base.lproj ├── LaunchScreen.storyboard └── Main.storyboard ├── Images ├── YBTextPicker1.gif ├── YBTextPicker2.gif ├── YBTextPicker3.gif ├── YBTextPicker4.gif ├── YBTextPicker_Logo.png ├── blue_ic_checked.png ├── green_ic_checked.png ├── green_ic_unchecked.png ├── red_ic_checked.png └── red_ic_unchecked.png ├── Info.plist ├── UIColor+HexString.swift ├── ViewController.swift └── YBTextPicker ├── Assets ├── YBTextPicker_checked.png └── YBTextPicker_unchecked.png ├── YBTextPicker.swift ├── YBTextPicker.xib ├── YBTextPickerCell ├── YBTextPickerCell.swift └── YBTextPickerCell.xib └── YBTextPickerDataModel.swift /LICENCE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Yahya Bagia 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # YBTextPicker 2 | Yet another text picker / selector written in swift 4.2. 3 | 4 | ![](https://github.com/YahyaBagia/YBTextPicker/blob/master/YBTextPicker/Images/YBTextPicker_Logo.png) 5 | 6 | ### Screenshots 7 | |![](https://github.com/YahyaBagia/YBTextPicker/blob/master/YBTextPicker/Images/YBTextPicker1.gif)|![](https://github.com/YahyaBagia/YBTextPicker/blob/master/YBTextPicker/Images/YBTextPicker2.gif)|![](https://github.com/YahyaBagia/YBTextPicker/blob/master/YBTextPicker/Images/YBTextPicker3.gif)|![](https://github.com/YahyaBagia/YBTextPicker/blob/master/YBTextPicker/Images/YBTextPicker4.gif)| 8 | | ------------- | ------------- | ------------- | -------------: | 9 | 10 | ### Installation 11 | Drag and Drop YBTextPicker Directory into your XCode Project Directory. 12 | 13 | ### Usage 14 | ``` 15 | let regularFont = UIFont.systemFont(ofSize: 16) 16 | let boldFont = UIFont.boldSystemFont(ofSize: 16) 17 | let blueColor = sender.backgroundColor 18 | 19 | let blueAppearance = YBTextPickerAppearanceManager.init( 20 | pickerTitle : "Select Fruits", 21 | titleFont : boldFont, 22 | titleTextColor : .black, 23 | titleBackground : .clear, 24 | searchBarFont : regularFont, 25 | searchBarPlaceholder: "Search Fruits", 26 | closeButtonTitle : "Cancel", 27 | closeButtonColor : .darkGray, 28 | closeButtonFont : regularFont, 29 | doneButtonTitle : "Done", 30 | doneButtonColor : blueColor, 31 | doneButtonFont : boldFont, 32 | checkMarkPosition : .Right, 33 | itemCheckedImage : UIImage(named:"blue_ic_checked"), 34 | itemUncheckedImage : UIImage(), 35 | itemColor : .black, 36 | itemFont : regularFont 37 | ) 38 | 39 | let fruits = ["Cherry", "Apricots", "Banana", "Blueberry", "Orange", "Apple", "Grapes", "Guava", "Mango", "Cherries", "Damson", "Grapefruit", "Pluot", "Plums", "Kiwi", "Peach", "Pear", "Pomegranate", "Starfruit", "Watermelon", "Pineapples"] 40 | let picker = YBTextPicker.init(with: fruits, appearance: blueAppearance, 41 | onCompletion: { (selectedIndexes, selectedValues) in 42 | if selectedValues.count > 0{ 43 | 44 | var values = [String]() 45 | for index in selectedIndexes{ 46 | values.append(fruits[index]) 47 | } 48 | 49 | self.btnFruitsPicker.setTitle(values.joined(separator: ", "), for: .normal) 50 | 51 | }else{ 52 | self.btnFruitsPicker.setTitle("Select Fruits", for: .normal) 53 | } 54 | }, 55 | onCancel: { 56 | print("Cancelled") 57 | } 58 | ) 59 | 60 | if let title = btnFruitsPicker.title(for: .normal){ 61 | if title.contains(","){ 62 | picker.preSelectedValues = title.components(separatedBy: ", ") 63 | } 64 | } 65 | picker.allowMultipleSelection = true 66 | 67 | picker.show(withAnimation: .Fade) 68 | ``` 69 | 70 | ### Requirements 71 | iOS 9.0+ 72 | 73 | ### License 74 | MIT License 75 | -------------------------------------------------------------------------------- /YBTextPicker.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 0807D70520E8EC0C0052CFEA /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0807D70420E8EC0C0052CFEA /* AppDelegate.swift */; }; 11 | 0807D70720E8EC0C0052CFEA /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0807D70620E8EC0C0052CFEA /* ViewController.swift */; }; 12 | 0807D70A20E8EC0C0052CFEA /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0807D70820E8EC0C0052CFEA /* Main.storyboard */; }; 13 | 0807D70C20E8EC0E0052CFEA /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0807D70B20E8EC0E0052CFEA /* Assets.xcassets */; }; 14 | 0807D70F20E8EC0E0052CFEA /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0807D70D20E8EC0E0052CFEA /* LaunchScreen.storyboard */; }; 15 | 0807D71C20E8ED160052CFEA /* YBTextPicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0807D71A20E8ED160052CFEA /* YBTextPicker.swift */; }; 16 | 0807D71D20E8ED160052CFEA /* YBTextPicker.xib in Resources */ = {isa = PBXBuildFile; fileRef = 0807D71B20E8ED160052CFEA /* YBTextPicker.xib */; }; 17 | 0807D72120E8F0200052CFEA /* YBTextPickerCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0807D71F20E8F0200052CFEA /* YBTextPickerCell.swift */; }; 18 | 0807D72220E8F0200052CFEA /* YBTextPickerCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 0807D72020E8F0200052CFEA /* YBTextPickerCell.xib */; }; 19 | 0807D73E20E91D980052CFEA /* YBTextPicker_unchecked.png in Resources */ = {isa = PBXBuildFile; fileRef = 0807D73C20E91D980052CFEA /* YBTextPicker_unchecked.png */; }; 20 | 0807D74220E925630052CFEA /* YBTextPicker_checked.png in Resources */ = {isa = PBXBuildFile; fileRef = 0807D74120E925630052CFEA /* YBTextPicker_checked.png */; }; 21 | 32029EC3223D791100186885 /* YBTextPicker_Logo.png in Resources */ = {isa = PBXBuildFile; fileRef = 32029EC2223D791000186885 /* YBTextPicker_Logo.png */; }; 22 | 32029ECB223D855300186885 /* red_ic_unchecked.png in Resources */ = {isa = PBXBuildFile; fileRef = 32029ECA223D855300186885 /* red_ic_unchecked.png */; }; 23 | 32029ECD223D855C00186885 /* red_ic_checked.png in Resources */ = {isa = PBXBuildFile; fileRef = 32029ECC223D855C00186885 /* red_ic_checked.png */; }; 24 | 32029ECF223D858200186885 /* green_ic_checked.png in Resources */ = {isa = PBXBuildFile; fileRef = 32029ECE223D858200186885 /* green_ic_checked.png */; }; 25 | 32029ED1223D859500186885 /* green_ic_unchecked.png in Resources */ = {isa = PBXBuildFile; fileRef = 32029ED0223D859500186885 /* green_ic_unchecked.png */; }; 26 | 32043657223AC7A90043C1A6 /* YBTextPickerDataModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32043656223AC7A90043C1A6 /* YBTextPickerDataModel.swift */; }; 27 | 3282904F224FF8AC003B3BF2 /* YBTextPicker1.gif in Resources */ = {isa = PBXBuildFile; fileRef = 3282904B224FF8AB003B3BF2 /* YBTextPicker1.gif */; }; 28 | 32829050224FF8AC003B3BF2 /* YBTextPicker3.gif in Resources */ = {isa = PBXBuildFile; fileRef = 3282904C224FF8AC003B3BF2 /* YBTextPicker3.gif */; }; 29 | 32829051224FF8AC003B3BF2 /* YBTextPicker4.gif in Resources */ = {isa = PBXBuildFile; fileRef = 3282904D224FF8AC003B3BF2 /* YBTextPicker4.gif */; }; 30 | 32829052224FF8AC003B3BF2 /* YBTextPicker2.gif in Resources */ = {isa = PBXBuildFile; fileRef = 3282904E224FF8AC003B3BF2 /* YBTextPicker2.gif */; }; 31 | 32894727223C12C200312E83 /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = 32894726223C12C200312E83 /* README.md */; }; 32 | 32894729223C12DE00312E83 /* LICENCE in Resources */ = {isa = PBXBuildFile; fileRef = 32894728223C12DE00312E83 /* LICENCE */; }; 33 | 32F91C5C224413BF002867DB /* blue_ic_checked.png in Resources */ = {isa = PBXBuildFile; fileRef = 32F91C5B224413BF002867DB /* blue_ic_checked.png */; }; 34 | 6B9387A2212B223A00E4C737 /* UIColor+HexString.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B9387A0212B223900E4C737 /* UIColor+HexString.swift */; }; 35 | /* End PBXBuildFile section */ 36 | 37 | /* Begin PBXFileReference section */ 38 | 0807D70120E8EC0C0052CFEA /* YBTextPicker.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = YBTextPicker.app; sourceTree = BUILT_PRODUCTS_DIR; }; 39 | 0807D70420E8EC0C0052CFEA /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 40 | 0807D70620E8EC0C0052CFEA /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 41 | 0807D70920E8EC0C0052CFEA /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 42 | 0807D70B20E8EC0E0052CFEA /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 43 | 0807D70E20E8EC0E0052CFEA /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 44 | 0807D71020E8EC0E0052CFEA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 45 | 0807D71A20E8ED160052CFEA /* YBTextPicker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YBTextPicker.swift; sourceTree = ""; }; 46 | 0807D71B20E8ED160052CFEA /* YBTextPicker.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = YBTextPicker.xib; sourceTree = ""; }; 47 | 0807D71F20E8F0200052CFEA /* YBTextPickerCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YBTextPickerCell.swift; sourceTree = ""; }; 48 | 0807D72020E8F0200052CFEA /* YBTextPickerCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = YBTextPickerCell.xib; sourceTree = ""; }; 49 | 0807D73C20E91D980052CFEA /* YBTextPicker_unchecked.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = YBTextPicker_unchecked.png; sourceTree = ""; }; 50 | 0807D74120E925630052CFEA /* YBTextPicker_checked.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = YBTextPicker_checked.png; sourceTree = ""; }; 51 | 32029EC2223D791000186885 /* YBTextPicker_Logo.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = YBTextPicker_Logo.png; sourceTree = ""; }; 52 | 32029ECA223D855300186885 /* red_ic_unchecked.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = red_ic_unchecked.png; sourceTree = ""; }; 53 | 32029ECC223D855C00186885 /* red_ic_checked.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = red_ic_checked.png; sourceTree = ""; }; 54 | 32029ECE223D858200186885 /* green_ic_checked.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = green_ic_checked.png; sourceTree = ""; }; 55 | 32029ED0223D859500186885 /* green_ic_unchecked.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = green_ic_unchecked.png; sourceTree = ""; }; 56 | 32043656223AC7A90043C1A6 /* YBTextPickerDataModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YBTextPickerDataModel.swift; sourceTree = ""; }; 57 | 3282904B224FF8AB003B3BF2 /* YBTextPicker1.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = YBTextPicker1.gif; sourceTree = ""; }; 58 | 3282904C224FF8AC003B3BF2 /* YBTextPicker3.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = YBTextPicker3.gif; sourceTree = ""; }; 59 | 3282904D224FF8AC003B3BF2 /* YBTextPicker4.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = YBTextPicker4.gif; sourceTree = ""; }; 60 | 3282904E224FF8AC003B3BF2 /* YBTextPicker2.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = YBTextPicker2.gif; sourceTree = ""; }; 61 | 32894726223C12C200312E83 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; 62 | 32894728223C12DE00312E83 /* LICENCE */ = {isa = PBXFileReference; lastKnownFileType = text; path = LICENCE; sourceTree = ""; }; 63 | 32F91C5B224413BF002867DB /* blue_ic_checked.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = blue_ic_checked.png; sourceTree = ""; }; 64 | 6B9387A0212B223900E4C737 /* UIColor+HexString.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIColor+HexString.swift"; sourceTree = ""; }; 65 | /* End PBXFileReference section */ 66 | 67 | /* Begin PBXFrameworksBuildPhase section */ 68 | 0807D6FE20E8EC0C0052CFEA /* Frameworks */ = { 69 | isa = PBXFrameworksBuildPhase; 70 | buildActionMask = 2147483647; 71 | files = ( 72 | ); 73 | runOnlyForDeploymentPostprocessing = 0; 74 | }; 75 | /* End PBXFrameworksBuildPhase section */ 76 | 77 | /* Begin PBXGroup section */ 78 | 0807D6F820E8EC0B0052CFEA = { 79 | isa = PBXGroup; 80 | children = ( 81 | 32894728223C12DE00312E83 /* LICENCE */, 82 | 32894726223C12C200312E83 /* README.md */, 83 | 0807D70320E8EC0C0052CFEA /* YBTextPicker */, 84 | 0807D70220E8EC0C0052CFEA /* Products */, 85 | ); 86 | sourceTree = ""; 87 | }; 88 | 0807D70220E8EC0C0052CFEA /* Products */ = { 89 | isa = PBXGroup; 90 | children = ( 91 | 0807D70120E8EC0C0052CFEA /* YBTextPicker.app */, 92 | ); 93 | name = Products; 94 | sourceTree = ""; 95 | }; 96 | 0807D70320E8EC0C0052CFEA /* YBTextPicker */ = { 97 | isa = PBXGroup; 98 | children = ( 99 | 321708FB223B524500B7C667 /* Images */, 100 | 0807D71620E8EC200052CFEA /* YBTextPicker */, 101 | 0807D70420E8EC0C0052CFEA /* AppDelegate.swift */, 102 | 0807D70620E8EC0C0052CFEA /* ViewController.swift */, 103 | 0807D70820E8EC0C0052CFEA /* Main.storyboard */, 104 | 6B9387A0212B223900E4C737 /* UIColor+HexString.swift */, 105 | 0807D70B20E8EC0E0052CFEA /* Assets.xcassets */, 106 | 0807D70D20E8EC0E0052CFEA /* LaunchScreen.storyboard */, 107 | 0807D71020E8EC0E0052CFEA /* Info.plist */, 108 | ); 109 | path = YBTextPicker; 110 | sourceTree = ""; 111 | }; 112 | 0807D71620E8EC200052CFEA /* YBTextPicker */ = { 113 | isa = PBXGroup; 114 | children = ( 115 | 0807D71720E8EC2D0052CFEA /* Assets */, 116 | 0807D71E20E8EFFF0052CFEA /* YBTextPickerCell */, 117 | 0807D71A20E8ED160052CFEA /* YBTextPicker.swift */, 118 | 0807D71B20E8ED160052CFEA /* YBTextPicker.xib */, 119 | 32043656223AC7A90043C1A6 /* YBTextPickerDataModel.swift */, 120 | ); 121 | path = YBTextPicker; 122 | sourceTree = ""; 123 | }; 124 | 0807D71720E8EC2D0052CFEA /* Assets */ = { 125 | isa = PBXGroup; 126 | children = ( 127 | 0807D74120E925630052CFEA /* YBTextPicker_checked.png */, 128 | 0807D73C20E91D980052CFEA /* YBTextPicker_unchecked.png */, 129 | ); 130 | path = Assets; 131 | sourceTree = ""; 132 | }; 133 | 0807D71E20E8EFFF0052CFEA /* YBTextPickerCell */ = { 134 | isa = PBXGroup; 135 | children = ( 136 | 0807D71F20E8F0200052CFEA /* YBTextPickerCell.swift */, 137 | 0807D72020E8F0200052CFEA /* YBTextPickerCell.xib */, 138 | ); 139 | path = YBTextPickerCell; 140 | sourceTree = ""; 141 | }; 142 | 321708FB223B524500B7C667 /* Images */ = { 143 | isa = PBXGroup; 144 | children = ( 145 | 32029EC2223D791000186885 /* YBTextPicker_Logo.png */, 146 | 3282904B224FF8AB003B3BF2 /* YBTextPicker1.gif */, 147 | 3282904E224FF8AC003B3BF2 /* YBTextPicker2.gif */, 148 | 3282904C224FF8AC003B3BF2 /* YBTextPicker3.gif */, 149 | 3282904D224FF8AC003B3BF2 /* YBTextPicker4.gif */, 150 | 32F91C5B224413BF002867DB /* blue_ic_checked.png */, 151 | 32029ECE223D858200186885 /* green_ic_checked.png */, 152 | 32029ED0223D859500186885 /* green_ic_unchecked.png */, 153 | 32029ECC223D855C00186885 /* red_ic_checked.png */, 154 | 32029ECA223D855300186885 /* red_ic_unchecked.png */, 155 | ); 156 | path = Images; 157 | sourceTree = ""; 158 | }; 159 | /* End PBXGroup section */ 160 | 161 | /* Begin PBXNativeTarget section */ 162 | 0807D70020E8EC0C0052CFEA /* YBTextPicker */ = { 163 | isa = PBXNativeTarget; 164 | buildConfigurationList = 0807D71320E8EC0E0052CFEA /* Build configuration list for PBXNativeTarget "YBTextPicker" */; 165 | buildPhases = ( 166 | 0807D6FD20E8EC0C0052CFEA /* Sources */, 167 | 0807D6FE20E8EC0C0052CFEA /* Frameworks */, 168 | 0807D6FF20E8EC0C0052CFEA /* Resources */, 169 | ); 170 | buildRules = ( 171 | ); 172 | dependencies = ( 173 | ); 174 | name = YBTextPicker; 175 | productName = YBTextPicker; 176 | productReference = 0807D70120E8EC0C0052CFEA /* YBTextPicker.app */; 177 | productType = "com.apple.product-type.application"; 178 | }; 179 | /* End PBXNativeTarget section */ 180 | 181 | /* Begin PBXProject section */ 182 | 0807D6F920E8EC0B0052CFEA /* Project object */ = { 183 | isa = PBXProject; 184 | attributes = { 185 | LastSwiftUpdateCheck = 0940; 186 | LastUpgradeCheck = 0940; 187 | ORGANIZATIONNAME = Yahya; 188 | TargetAttributes = { 189 | 0807D70020E8EC0C0052CFEA = { 190 | CreatedOnToolsVersion = 9.4.1; 191 | }; 192 | }; 193 | }; 194 | buildConfigurationList = 0807D6FC20E8EC0B0052CFEA /* Build configuration list for PBXProject "YBTextPicker" */; 195 | compatibilityVersion = "Xcode 9.3"; 196 | developmentRegion = en; 197 | hasScannedForEncodings = 0; 198 | knownRegions = ( 199 | en, 200 | Base, 201 | ); 202 | mainGroup = 0807D6F820E8EC0B0052CFEA; 203 | productRefGroup = 0807D70220E8EC0C0052CFEA /* Products */; 204 | projectDirPath = ""; 205 | projectRoot = ""; 206 | targets = ( 207 | 0807D70020E8EC0C0052CFEA /* YBTextPicker */, 208 | ); 209 | }; 210 | /* End PBXProject section */ 211 | 212 | /* Begin PBXResourcesBuildPhase section */ 213 | 0807D6FF20E8EC0C0052CFEA /* Resources */ = { 214 | isa = PBXResourcesBuildPhase; 215 | buildActionMask = 2147483647; 216 | files = ( 217 | 32829052224FF8AC003B3BF2 /* YBTextPicker2.gif in Resources */, 218 | 32894729223C12DE00312E83 /* LICENCE in Resources */, 219 | 0807D70F20E8EC0E0052CFEA /* LaunchScreen.storyboard in Resources */, 220 | 32F91C5C224413BF002867DB /* blue_ic_checked.png in Resources */, 221 | 32829051224FF8AC003B3BF2 /* YBTextPicker4.gif in Resources */, 222 | 32029ECD223D855C00186885 /* red_ic_checked.png in Resources */, 223 | 3282904F224FF8AC003B3BF2 /* YBTextPicker1.gif in Resources */, 224 | 0807D70C20E8EC0E0052CFEA /* Assets.xcassets in Resources */, 225 | 0807D72220E8F0200052CFEA /* YBTextPickerCell.xib in Resources */, 226 | 0807D74220E925630052CFEA /* YBTextPicker_checked.png in Resources */, 227 | 32029ECF223D858200186885 /* green_ic_checked.png in Resources */, 228 | 0807D70A20E8EC0C0052CFEA /* Main.storyboard in Resources */, 229 | 32029EC3223D791100186885 /* YBTextPicker_Logo.png in Resources */, 230 | 32829050224FF8AC003B3BF2 /* YBTextPicker3.gif in Resources */, 231 | 0807D71D20E8ED160052CFEA /* YBTextPicker.xib in Resources */, 232 | 32894727223C12C200312E83 /* README.md in Resources */, 233 | 32029ECB223D855300186885 /* red_ic_unchecked.png in Resources */, 234 | 0807D73E20E91D980052CFEA /* YBTextPicker_unchecked.png in Resources */, 235 | 32029ED1223D859500186885 /* green_ic_unchecked.png in Resources */, 236 | ); 237 | runOnlyForDeploymentPostprocessing = 0; 238 | }; 239 | /* End PBXResourcesBuildPhase section */ 240 | 241 | /* Begin PBXSourcesBuildPhase section */ 242 | 0807D6FD20E8EC0C0052CFEA /* Sources */ = { 243 | isa = PBXSourcesBuildPhase; 244 | buildActionMask = 2147483647; 245 | files = ( 246 | 6B9387A2212B223A00E4C737 /* UIColor+HexString.swift in Sources */, 247 | 0807D70720E8EC0C0052CFEA /* ViewController.swift in Sources */, 248 | 32043657223AC7A90043C1A6 /* YBTextPickerDataModel.swift in Sources */, 249 | 0807D70520E8EC0C0052CFEA /* AppDelegate.swift in Sources */, 250 | 0807D71C20E8ED160052CFEA /* YBTextPicker.swift in Sources */, 251 | 0807D72120E8F0200052CFEA /* YBTextPickerCell.swift in Sources */, 252 | ); 253 | runOnlyForDeploymentPostprocessing = 0; 254 | }; 255 | /* End PBXSourcesBuildPhase section */ 256 | 257 | /* Begin PBXVariantGroup section */ 258 | 0807D70820E8EC0C0052CFEA /* Main.storyboard */ = { 259 | isa = PBXVariantGroup; 260 | children = ( 261 | 0807D70920E8EC0C0052CFEA /* Base */, 262 | ); 263 | name = Main.storyboard; 264 | sourceTree = ""; 265 | }; 266 | 0807D70D20E8EC0E0052CFEA /* LaunchScreen.storyboard */ = { 267 | isa = PBXVariantGroup; 268 | children = ( 269 | 0807D70E20E8EC0E0052CFEA /* Base */, 270 | ); 271 | name = LaunchScreen.storyboard; 272 | sourceTree = ""; 273 | }; 274 | /* End PBXVariantGroup section */ 275 | 276 | /* Begin XCBuildConfiguration section */ 277 | 0807D71120E8EC0E0052CFEA /* Debug */ = { 278 | isa = XCBuildConfiguration; 279 | buildSettings = { 280 | ALWAYS_SEARCH_USER_PATHS = NO; 281 | CLANG_ANALYZER_NONNULL = YES; 282 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 283 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 284 | CLANG_CXX_LIBRARY = "libc++"; 285 | CLANG_ENABLE_MODULES = YES; 286 | CLANG_ENABLE_OBJC_ARC = YES; 287 | CLANG_ENABLE_OBJC_WEAK = YES; 288 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 289 | CLANG_WARN_BOOL_CONVERSION = YES; 290 | CLANG_WARN_COMMA = YES; 291 | CLANG_WARN_CONSTANT_CONVERSION = YES; 292 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 293 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 294 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 295 | CLANG_WARN_EMPTY_BODY = YES; 296 | CLANG_WARN_ENUM_CONVERSION = YES; 297 | CLANG_WARN_INFINITE_RECURSION = YES; 298 | CLANG_WARN_INT_CONVERSION = YES; 299 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 300 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 301 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 302 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 303 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 304 | CLANG_WARN_STRICT_PROTOTYPES = YES; 305 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 306 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 307 | CLANG_WARN_UNREACHABLE_CODE = YES; 308 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 309 | CODE_SIGN_IDENTITY = "iPhone Developer"; 310 | COPY_PHASE_STRIP = NO; 311 | DEBUG_INFORMATION_FORMAT = dwarf; 312 | ENABLE_STRICT_OBJC_MSGSEND = YES; 313 | ENABLE_TESTABILITY = YES; 314 | GCC_C_LANGUAGE_STANDARD = gnu11; 315 | GCC_DYNAMIC_NO_PIC = NO; 316 | GCC_NO_COMMON_BLOCKS = YES; 317 | GCC_OPTIMIZATION_LEVEL = 0; 318 | GCC_PREPROCESSOR_DEFINITIONS = ( 319 | "DEBUG=1", 320 | "$(inherited)", 321 | ); 322 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 323 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 324 | GCC_WARN_UNDECLARED_SELECTOR = YES; 325 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 326 | GCC_WARN_UNUSED_FUNCTION = YES; 327 | GCC_WARN_UNUSED_VARIABLE = YES; 328 | IPHONEOS_DEPLOYMENT_TARGET = 11.4; 329 | MTL_ENABLE_DEBUG_INFO = YES; 330 | ONLY_ACTIVE_ARCH = YES; 331 | SDKROOT = iphoneos; 332 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 333 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 334 | }; 335 | name = Debug; 336 | }; 337 | 0807D71220E8EC0E0052CFEA /* Release */ = { 338 | isa = XCBuildConfiguration; 339 | buildSettings = { 340 | ALWAYS_SEARCH_USER_PATHS = NO; 341 | CLANG_ANALYZER_NONNULL = YES; 342 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 343 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 344 | CLANG_CXX_LIBRARY = "libc++"; 345 | CLANG_ENABLE_MODULES = YES; 346 | CLANG_ENABLE_OBJC_ARC = YES; 347 | CLANG_ENABLE_OBJC_WEAK = YES; 348 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 349 | CLANG_WARN_BOOL_CONVERSION = YES; 350 | CLANG_WARN_COMMA = YES; 351 | CLANG_WARN_CONSTANT_CONVERSION = YES; 352 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 353 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 354 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 355 | CLANG_WARN_EMPTY_BODY = YES; 356 | CLANG_WARN_ENUM_CONVERSION = YES; 357 | CLANG_WARN_INFINITE_RECURSION = YES; 358 | CLANG_WARN_INT_CONVERSION = YES; 359 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 360 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 361 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 362 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 363 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 364 | CLANG_WARN_STRICT_PROTOTYPES = YES; 365 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 366 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 367 | CLANG_WARN_UNREACHABLE_CODE = YES; 368 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 369 | CODE_SIGN_IDENTITY = "iPhone Developer"; 370 | COPY_PHASE_STRIP = NO; 371 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 372 | ENABLE_NS_ASSERTIONS = NO; 373 | ENABLE_STRICT_OBJC_MSGSEND = YES; 374 | GCC_C_LANGUAGE_STANDARD = gnu11; 375 | GCC_NO_COMMON_BLOCKS = YES; 376 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 377 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 378 | GCC_WARN_UNDECLARED_SELECTOR = YES; 379 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 380 | GCC_WARN_UNUSED_FUNCTION = YES; 381 | GCC_WARN_UNUSED_VARIABLE = YES; 382 | IPHONEOS_DEPLOYMENT_TARGET = 11.4; 383 | MTL_ENABLE_DEBUG_INFO = NO; 384 | SDKROOT = iphoneos; 385 | SWIFT_COMPILATION_MODE = wholemodule; 386 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 387 | VALIDATE_PRODUCT = YES; 388 | }; 389 | name = Release; 390 | }; 391 | 0807D71420E8EC0E0052CFEA /* Debug */ = { 392 | isa = XCBuildConfiguration; 393 | buildSettings = { 394 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 395 | CODE_SIGN_STYLE = Automatic; 396 | DEVELOPMENT_TEAM = 69AXYX9773; 397 | INFOPLIST_FILE = YBTextPicker/Info.plist; 398 | LD_RUNPATH_SEARCH_PATHS = ( 399 | "$(inherited)", 400 | "@executable_path/Frameworks", 401 | ); 402 | PRODUCT_BUNDLE_IDENTIFIER = com.yahya.YBTextPicker; 403 | PRODUCT_NAME = "$(TARGET_NAME)"; 404 | SWIFT_VERSION = 4.2; 405 | TARGETED_DEVICE_FAMILY = "1,2"; 406 | }; 407 | name = Debug; 408 | }; 409 | 0807D71520E8EC0E0052CFEA /* Release */ = { 410 | isa = XCBuildConfiguration; 411 | buildSettings = { 412 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 413 | CODE_SIGN_STYLE = Automatic; 414 | DEVELOPMENT_TEAM = 69AXYX9773; 415 | INFOPLIST_FILE = YBTextPicker/Info.plist; 416 | LD_RUNPATH_SEARCH_PATHS = ( 417 | "$(inherited)", 418 | "@executable_path/Frameworks", 419 | ); 420 | PRODUCT_BUNDLE_IDENTIFIER = com.yahya.YBTextPicker; 421 | PRODUCT_NAME = "$(TARGET_NAME)"; 422 | SWIFT_VERSION = 4.2; 423 | TARGETED_DEVICE_FAMILY = "1,2"; 424 | }; 425 | name = Release; 426 | }; 427 | /* End XCBuildConfiguration section */ 428 | 429 | /* Begin XCConfigurationList section */ 430 | 0807D6FC20E8EC0B0052CFEA /* Build configuration list for PBXProject "YBTextPicker" */ = { 431 | isa = XCConfigurationList; 432 | buildConfigurations = ( 433 | 0807D71120E8EC0E0052CFEA /* Debug */, 434 | 0807D71220E8EC0E0052CFEA /* Release */, 435 | ); 436 | defaultConfigurationIsVisible = 0; 437 | defaultConfigurationName = Release; 438 | }; 439 | 0807D71320E8EC0E0052CFEA /* Build configuration list for PBXNativeTarget "YBTextPicker" */ = { 440 | isa = XCConfigurationList; 441 | buildConfigurations = ( 442 | 0807D71420E8EC0E0052CFEA /* Debug */, 443 | 0807D71520E8EC0E0052CFEA /* Release */, 444 | ); 445 | defaultConfigurationIsVisible = 0; 446 | defaultConfigurationName = Release; 447 | }; 448 | /* End XCConfigurationList section */ 449 | }; 450 | rootObject = 0807D6F920E8EC0B0052CFEA /* Project object */; 451 | } 452 | -------------------------------------------------------------------------------- /YBTextPicker.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /YBTextPicker.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /YBTextPicker.xcodeproj/xcuserdata/krishna.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /YBTextPicker.xcodeproj/xcuserdata/krishna.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | YBTextPicker.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /YBTextPicker.xcodeproj/xcuserdata/yahya.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /YBTextPicker.xcodeproj/xcuserdata/yahya.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | YBTextPicker.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /YBTextPicker.xcodeproj/xcuserdata/yahyabagia.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /YBTextPicker.xcodeproj/xcuserdata/yahyabagia.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | YBTextPicker.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /YBTextPicker/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // YBTextPicker 4 | // 5 | // Created by Yahya on 01/07/18. 6 | // Copyright © 2018 Yahya. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool { 17 | return true 18 | } 19 | 20 | } 21 | 22 | -------------------------------------------------------------------------------- /YBTextPicker/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-App-20x20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-App-20x20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-App-29x29@2x.png", 19 | "scale" : "2x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-App-29x29@3x.png", 25 | "scale" : "3x" 26 | }, 27 | { 28 | "size" : "40x40", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-App-40x40@2x.png", 31 | "scale" : "2x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-App-40x40@3x.png", 37 | "scale" : "3x" 38 | }, 39 | { 40 | "size" : "60x60", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-App-60x60@2x.png", 43 | "scale" : "2x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-App-60x60@3x.png", 49 | "scale" : "3x" 50 | }, 51 | { 52 | "size" : "20x20", 53 | "idiom" : "ipad", 54 | "filename" : "Icon-App-20x20@1x.png", 55 | "scale" : "1x" 56 | }, 57 | { 58 | "size" : "20x20", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-App-20x20@2x-1.png", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "size" : "29x29", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-App-29x29@1x.png", 67 | "scale" : "1x" 68 | }, 69 | { 70 | "size" : "29x29", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-App-29x29@2x-1.png", 73 | "scale" : "2x" 74 | }, 75 | { 76 | "size" : "40x40", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-App-40x40@1x.png", 79 | "scale" : "1x" 80 | }, 81 | { 82 | "size" : "40x40", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-App-40x40@2x-1.png", 85 | "scale" : "2x" 86 | }, 87 | { 88 | "size" : "76x76", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-App-76x76@1x.png", 91 | "scale" : "1x" 92 | }, 93 | { 94 | "size" : "76x76", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-App-76x76@2x.png", 97 | "scale" : "2x" 98 | }, 99 | { 100 | "size" : "83.5x83.5", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-App-83.5x83.5@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "1024x1024", 107 | "idiom" : "ios-marketing", 108 | "filename" : "ItunesArtwork@2x.png", 109 | "scale" : "1x" 110 | } 111 | ], 112 | "info" : { 113 | "version" : 1, 114 | "author" : "xcode" 115 | } 116 | } -------------------------------------------------------------------------------- /YBTextPicker/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YahyaBagia/YBTextPicker/ac25e21b9bce7980925d1342e80a6f760310d5e0/YBTextPicker/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /YBTextPicker/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YahyaBagia/YBTextPicker/ac25e21b9bce7980925d1342e80a6f760310d5e0/YBTextPicker/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x-1.png -------------------------------------------------------------------------------- /YBTextPicker/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YahyaBagia/YBTextPicker/ac25e21b9bce7980925d1342e80a6f760310d5e0/YBTextPicker/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /YBTextPicker/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YahyaBagia/YBTextPicker/ac25e21b9bce7980925d1342e80a6f760310d5e0/YBTextPicker/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /YBTextPicker/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YahyaBagia/YBTextPicker/ac25e21b9bce7980925d1342e80a6f760310d5e0/YBTextPicker/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /YBTextPicker/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YahyaBagia/YBTextPicker/ac25e21b9bce7980925d1342e80a6f760310d5e0/YBTextPicker/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x-1.png -------------------------------------------------------------------------------- /YBTextPicker/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YahyaBagia/YBTextPicker/ac25e21b9bce7980925d1342e80a6f760310d5e0/YBTextPicker/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /YBTextPicker/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YahyaBagia/YBTextPicker/ac25e21b9bce7980925d1342e80a6f760310d5e0/YBTextPicker/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /YBTextPicker/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YahyaBagia/YBTextPicker/ac25e21b9bce7980925d1342e80a6f760310d5e0/YBTextPicker/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /YBTextPicker/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YahyaBagia/YBTextPicker/ac25e21b9bce7980925d1342e80a6f760310d5e0/YBTextPicker/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x-1.png -------------------------------------------------------------------------------- /YBTextPicker/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YahyaBagia/YBTextPicker/ac25e21b9bce7980925d1342e80a6f760310d5e0/YBTextPicker/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /YBTextPicker/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YahyaBagia/YBTextPicker/ac25e21b9bce7980925d1342e80a6f760310d5e0/YBTextPicker/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /YBTextPicker/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YahyaBagia/YBTextPicker/ac25e21b9bce7980925d1342e80a6f760310d5e0/YBTextPicker/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /YBTextPicker/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YahyaBagia/YBTextPicker/ac25e21b9bce7980925d1342e80a6f760310d5e0/YBTextPicker/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /YBTextPicker/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YahyaBagia/YBTextPicker/ac25e21b9bce7980925d1342e80a6f760310d5e0/YBTextPicker/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /YBTextPicker/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YahyaBagia/YBTextPicker/ac25e21b9bce7980925d1342e80a6f760310d5e0/YBTextPicker/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /YBTextPicker/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YahyaBagia/YBTextPicker/ac25e21b9bce7980925d1342e80a6f760310d5e0/YBTextPicker/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /YBTextPicker/Assets.xcassets/AppIcon.appiconset/ItunesArtwork@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YahyaBagia/YBTextPicker/ac25e21b9bce7980925d1342e80a6f760310d5e0/YBTextPicker/Assets.xcassets/AppIcon.appiconset/ItunesArtwork@2x.png -------------------------------------------------------------------------------- /YBTextPicker/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /YBTextPicker/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /YBTextPicker/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 53 | 65 | 77 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | -------------------------------------------------------------------------------- /YBTextPicker/Images/YBTextPicker1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YahyaBagia/YBTextPicker/ac25e21b9bce7980925d1342e80a6f760310d5e0/YBTextPicker/Images/YBTextPicker1.gif -------------------------------------------------------------------------------- /YBTextPicker/Images/YBTextPicker2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YahyaBagia/YBTextPicker/ac25e21b9bce7980925d1342e80a6f760310d5e0/YBTextPicker/Images/YBTextPicker2.gif -------------------------------------------------------------------------------- /YBTextPicker/Images/YBTextPicker3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YahyaBagia/YBTextPicker/ac25e21b9bce7980925d1342e80a6f760310d5e0/YBTextPicker/Images/YBTextPicker3.gif -------------------------------------------------------------------------------- /YBTextPicker/Images/YBTextPicker4.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YahyaBagia/YBTextPicker/ac25e21b9bce7980925d1342e80a6f760310d5e0/YBTextPicker/Images/YBTextPicker4.gif -------------------------------------------------------------------------------- /YBTextPicker/Images/YBTextPicker_Logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YahyaBagia/YBTextPicker/ac25e21b9bce7980925d1342e80a6f760310d5e0/YBTextPicker/Images/YBTextPicker_Logo.png -------------------------------------------------------------------------------- /YBTextPicker/Images/blue_ic_checked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YahyaBagia/YBTextPicker/ac25e21b9bce7980925d1342e80a6f760310d5e0/YBTextPicker/Images/blue_ic_checked.png -------------------------------------------------------------------------------- /YBTextPicker/Images/green_ic_checked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YahyaBagia/YBTextPicker/ac25e21b9bce7980925d1342e80a6f760310d5e0/YBTextPicker/Images/green_ic_checked.png -------------------------------------------------------------------------------- /YBTextPicker/Images/green_ic_unchecked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YahyaBagia/YBTextPicker/ac25e21b9bce7980925d1342e80a6f760310d5e0/YBTextPicker/Images/green_ic_unchecked.png -------------------------------------------------------------------------------- /YBTextPicker/Images/red_ic_checked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YahyaBagia/YBTextPicker/ac25e21b9bce7980925d1342e80a6f760310d5e0/YBTextPicker/Images/red_ic_checked.png -------------------------------------------------------------------------------- /YBTextPicker/Images/red_ic_unchecked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YahyaBagia/YBTextPicker/ac25e21b9bce7980925d1342e80a6f760310d5e0/YBTextPicker/Images/red_ic_unchecked.png -------------------------------------------------------------------------------- /YBTextPicker/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /YBTextPicker/UIColor+HexString.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIColor+HexString.swift 3 | // SwiftProjectStructure 4 | // 5 | // Created by EbitM02 on 19/06/18. 6 | // Copyright © 2018 Krishna. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | 12 | extension UIColor { 13 | convenience init(hexString: String) { 14 | let hex = hexString.trimmingCharacters(in: CharacterSet.alphanumerics.inverted) 15 | var int = UInt32() 16 | Scanner(string: hex).scanHexInt32(&int) 17 | let a, r, g, b: UInt32 18 | switch hex.count { 19 | case 3: // RGB (12-bit) 20 | (a, r, g, b) = (255, (int >> 8) * 17, (int >> 4 & 0xF) * 17, (int & 0xF) * 17) 21 | case 6: // RGB (24-bit) 22 | (a, r, g, b) = (255, int >> 16, int >> 8 & 0xFF, int & 0xFF) 23 | case 8: // ARGB (32-bit) 24 | (a, r, g, b) = (int >> 24, int >> 16 & 0xFF, int >> 8 & 0xFF, int & 0xFF) 25 | default: 26 | (a, r, g, b) = (255, 0, 0, 0) 27 | } 28 | self.init(red: CGFloat(r) / 255, green: CGFloat(g) / 255, blue: CGFloat(b) / 255, alpha: CGFloat(a) / 255) 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /YBTextPicker/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // YBTextPicker 4 | // 5 | // Created by Yahya on 01/07/18. 6 | // Copyright © 2018 Yahya. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UIViewController { 12 | 13 | let regularFont = UIFont.systemFont(ofSize: 16) 14 | let boldFont = UIFont.boldSystemFont(ofSize: 16) 15 | 16 | @IBOutlet weak var btnFruitsPicker: UIButton! 17 | @IBOutlet weak var btnCountyPicker: UIButton! 18 | @IBOutlet weak var btnThemePicker: UIButton! 19 | @IBOutlet weak var btnGenderPicker: UIButton! 20 | 21 | override func viewDidLoad() { 22 | super.viewDidLoad() 23 | } 24 | 25 | override func didReceiveMemoryWarning() { 26 | super.didReceiveMemoryWarning() 27 | } 28 | 29 | @IBAction func openFruitsPickerAction(_ sender:UIButton) { 30 | let blueColor = sender.backgroundColor 31 | 32 | let blueAppearance = YBTextPickerAppearanceManager.init( 33 | pickerTitle : "Select Fruits", 34 | titleFont : boldFont, 35 | titleTextColor : .black, 36 | titleBackground : .clear, 37 | searchBarFont : regularFont, 38 | searchBarPlaceholder: "Search Fruits", 39 | closeButtonTitle : "Cancel", 40 | closeButtonColor : .darkGray, 41 | closeButtonFont : regularFont, 42 | doneButtonTitle : "Done", 43 | doneButtonColor : blueColor, 44 | doneButtonFont : boldFont, 45 | checkMarkPosition : .Right, 46 | itemCheckedImage : UIImage(named:"blue_ic_checked"), 47 | itemUncheckedImage : UIImage(), 48 | itemColor : .black, 49 | itemFont : regularFont 50 | ) 51 | 52 | let fruits = ["Cherry", "Apricots", "Banana", "Blueberry", "Orange", "Apple", "Grapes", "Guava", "Mango", "Cherries", "Damson", "Grapefruit", "Pluot", "Plums", "Kiwi", "Peach", "Pear", "Pomegranate", "Starfruit", "Watermelon", "Pineapples"] 53 | let picker = YBTextPicker.init(with: fruits, appearance: blueAppearance, 54 | onCompletion: { (selectedIndexes, selectedValues) in 55 | if selectedValues.count > 0{ 56 | 57 | var values = [String]() 58 | for index in selectedIndexes{ 59 | values.append(fruits[index]) 60 | } 61 | 62 | self.btnFruitsPicker.setTitle(values.joined(separator: ", "), for: .normal) 63 | 64 | }else{ 65 | self.btnFruitsPicker.setTitle("Select Fruits", for: .normal) 66 | } 67 | }, 68 | onCancel: { 69 | print("Cancelled") 70 | } 71 | ) 72 | 73 | if let title = btnFruitsPicker.title(for: .normal){ 74 | if title.contains(","){ 75 | picker.preSelectedValues = title.components(separatedBy: ", ") 76 | } 77 | } 78 | picker.allowMultipleSelection = true 79 | 80 | picker.show(withAnimation: .Fade) 81 | } 82 | 83 | @IBAction func openCountriesPickerAction(_ sender: UIButton) { 84 | let greenColor = sender.backgroundColor 85 | 86 | let greenAppearance = YBTextPickerAppearanceManager.init( 87 | pickerTitle : "Select Countries", 88 | titleFont : boldFont, 89 | titleTextColor : .white, 90 | titleBackground : greenColor, 91 | searchBarFont : regularFont, 92 | searchBarPlaceholder: "Search Countries", 93 | closeButtonTitle : "Cancel", 94 | closeButtonColor : .darkGray, 95 | closeButtonFont : regularFont, 96 | doneButtonTitle : "Okay", 97 | doneButtonColor : greenColor, 98 | doneButtonFont : boldFont, 99 | checkMarkPosition : .Left, 100 | itemCheckedImage : UIImage(named:"green_ic_checked"), 101 | itemUncheckedImage : UIImage(named:"green_ic_unchecked"), 102 | itemColor : .black, 103 | itemFont : regularFont 104 | ) 105 | 106 | let countries = ["India", "Bangladesh", "Sri-Lanka", "Japan", "United States", "United Kingdom", "United Arab Emirates", "Egypt", "France", "Russia", "Poland", "Australia", "New Zealand", "Saudi Arabia", "South Africa", "Somalia", "Turkey", "Ukraine"] 107 | let picker = YBTextPicker.init(with: countries, appearance: greenAppearance, 108 | onCompletion: { (selectedIndexes, selectedValues) in 109 | if selectedValues.count > 0{ 110 | 111 | var values = [String]() 112 | for index in selectedIndexes{ 113 | values.append(countries[index]) 114 | } 115 | 116 | self.btnCountyPicker.setTitle(values.joined(separator: ", "), for: .normal) 117 | 118 | }else{ 119 | self.btnCountyPicker.setTitle("Select Countries", for: .normal) 120 | } 121 | }, 122 | onCancel: { 123 | print("Cancelled") 124 | } 125 | ) 126 | 127 | if let title = btnCountyPicker.title(for: .normal){ 128 | if title.contains(","){ 129 | picker.preSelectedValues = title.components(separatedBy: ", ") 130 | } 131 | } 132 | picker.allowMultipleSelection = true 133 | 134 | picker.show(withAnimation: .Fade) 135 | } 136 | 137 | @IBAction func openThemePickerAction(_ sender: Any) { 138 | 139 | let theme = YBTextPickerAppearanceManager.init( 140 | pickerTitle : "Pick a Theme", 141 | titleFont : boldFont, 142 | titleTextColor : .white, 143 | titleBackground : nil, 144 | searchBarFont : regularFont, 145 | searchBarPlaceholder: "Search Countries", 146 | closeButtonTitle : "Cancel", 147 | closeButtonColor : .darkGray, 148 | closeButtonFont : regularFont, 149 | doneButtonTitle : "Okay", 150 | doneButtonColor : nil, 151 | doneButtonFont : boldFont, 152 | checkMarkPosition : .Right, 153 | itemCheckedImage : nil, 154 | itemUncheckedImage : nil, 155 | itemColor : .black, 156 | itemFont : regularFont 157 | ) 158 | 159 | let arrTheme = ["Dracula", "Opa", "Moss"] 160 | let picker = YBTextPicker.init(with: arrTheme, appearance: theme, onCompletion: { (selectedIndexes, selectedValues) in 161 | if let selectedValue = selectedValues.first{ 162 | self.btnThemePicker.setTitle(selectedValue, for: .normal) 163 | }else{ 164 | self.btnThemePicker.setTitle("Pick a theme", for: .normal) 165 | } 166 | }, onCancel: { 167 | 168 | }) 169 | picker.show(withAnimation: .FromBottom) 170 | } 171 | 172 | @IBAction func openGenderPickerAction(_ sender: UIButton) { 173 | 174 | let redAppearance = YBTextPickerAppearanceManager.init( 175 | pickerTitle : "What's your gender?", 176 | titleFont : boldFont, 177 | titleTextColor : .white, 178 | titleBackground : sender.backgroundColor, 179 | searchBarFont : regularFont, 180 | searchBarPlaceholder: "Search Gender", 181 | closeButtonTitle : "Cancel", 182 | closeButtonColor : .darkGray, 183 | closeButtonFont : regularFont, 184 | doneButtonTitle : "Okay", 185 | doneButtonColor : sender.backgroundColor, 186 | doneButtonFont : boldFont, 187 | checkMarkPosition : .Right, 188 | itemCheckedImage : UIImage(named:"red_ic_checked"), 189 | itemUncheckedImage : UIImage(named:"red_ic_unchecked"), 190 | itemColor : .black, 191 | itemFont : regularFont 192 | ) 193 | 194 | let arrGender = ["Male", "Female", "Prefer not to Say"] 195 | let picker = YBTextPicker.init(with: arrGender, appearance: redAppearance, 196 | onCompletion: { (selectedIndexes, selectedValues) in 197 | if let selectedValue = selectedValues.first{ 198 | if selectedValue == arrGender.last!{ 199 | self.btnGenderPicker.setTitle("I'm a human", for: .normal) 200 | }else{ 201 | self.btnGenderPicker.setTitle("I'm \(selectedValue)", for: .normal) 202 | } 203 | }else{ 204 | self.btnGenderPicker.setTitle("What's your gender?", for: .normal) 205 | } 206 | }, 207 | onCancel: { 208 | print("Cancelled") 209 | } 210 | ) 211 | 212 | picker.show(withAnimation: .FromBottom) 213 | } 214 | 215 | } 216 | -------------------------------------------------------------------------------- /YBTextPicker/YBTextPicker/Assets/YBTextPicker_checked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YahyaBagia/YBTextPicker/ac25e21b9bce7980925d1342e80a6f760310d5e0/YBTextPicker/YBTextPicker/Assets/YBTextPicker_checked.png -------------------------------------------------------------------------------- /YBTextPicker/YBTextPicker/Assets/YBTextPicker_unchecked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YahyaBagia/YBTextPicker/ac25e21b9bce7980925d1342e80a6f760310d5e0/YBTextPicker/YBTextPicker/Assets/YBTextPicker_unchecked.png -------------------------------------------------------------------------------- /YBTextPicker/YBTextPicker/YBTextPicker.swift: -------------------------------------------------------------------------------- 1 | // 2 | // YBTextPicker.swift 3 | // YBTextPicker 4 | // 5 | // Created by Yahya on 01/07/18. 6 | // Copyright © 2018 Yahya. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | enum YBTextPickerAnimation:String{ 12 | case FromBottom 13 | case Fade 14 | } 15 | 16 | enum YBTextPickerCheckMarkPosition:String{ 17 | case Left 18 | case Right 19 | } 20 | 21 | struct YBTextPickerAppearanceManager{ 22 | 23 | var pickerTitle : String? 24 | var titleFont : UIFont? 25 | var titleTextColor : UIColor? 26 | var titleBackground : UIColor? 27 | 28 | var searchBarFont : UIFont? 29 | var searchBarPlaceholder : String? 30 | 31 | var closeButtonTitle : String? 32 | var closeButtonColor : UIColor? 33 | var closeButtonFont : UIFont? 34 | 35 | var doneButtonTitle : String? 36 | var doneButtonColor : UIColor? 37 | var doneButtonFont : UIFont? 38 | 39 | var checkMarkPosition : YBTextPickerCheckMarkPosition? 40 | var itemCheckedImage : UIImage? 41 | var itemUncheckedImage : UIImage? 42 | var itemColor : UIColor? 43 | var itemFont : UIFont? 44 | 45 | } 46 | 47 | class YBTextPicker: UIViewController { 48 | 49 | //MARK:- Constants 50 | let animationDuration = 0.3 51 | let shadowAmount:CGFloat = 0.6 52 | let shadowColor = UIColor.black 53 | 54 | //MARK:- IBOutlets 55 | @IBOutlet var tapToDismissGesture: UITapGestureRecognizer! 56 | @IBOutlet weak var shadowView: UIView! 57 | @IBOutlet weak var containerView: UIView! 58 | @IBOutlet weak var titleLabel: UILabel! 59 | @IBOutlet weak var txtSearch: UISearchBar! 60 | @IBOutlet weak var tableView: UITableView! 61 | @IBOutlet weak var btnClose: UIButton! 62 | @IBOutlet weak var btnDone: UIButton! 63 | 64 | //MARK:- Constraints 65 | @IBOutlet weak var paddingToTop: NSLayoutConstraint! 66 | @IBOutlet weak var paddingToBottom: NSLayoutConstraint! 67 | @IBOutlet weak var paddingToLeft: NSLayoutConstraint! 68 | @IBOutlet weak var paddingToRight: NSLayoutConstraint! 69 | 70 | //MARK:- Properties 71 | var arrAllValues = [YBTextPickerDataModel]() 72 | var arrValues = [YBTextPickerDataModel]() 73 | 74 | var selectedValues = [YBTextPickerDataModel]() 75 | 76 | var preSelectedValues = [String]() 77 | 78 | var allowMultipleSelection = false 79 | var tapToDismiss = true 80 | var animation = YBTextPickerAnimation.FromBottom 81 | var appearanceManager : YBTextPickerAppearanceManager? 82 | 83 | var completionHandler : ((_ selectedIndexes:[Int], _ selectedValues:[String])->Void)? 84 | var cancelHandler : (()->Void)? 85 | 86 | init ( 87 | with items : [String], 88 | appearance : YBTextPickerAppearanceManager?, 89 | onCompletion : @escaping (_ selectedIndexes:[Int], _ selectedValues:[String]) -> Void, 90 | onCancel : @escaping () -> Void 91 | ){ 92 | 93 | super.init(nibName: "YBTextPicker", bundle: nil) 94 | 95 | for (index,textItem) in items.enumerated(){ 96 | let dataModel = YBTextPickerDataModel.init(textItem, index) 97 | arrAllValues.append(dataModel) 98 | } 99 | 100 | self.arrValues = arrAllValues.map{$0} 101 | 102 | self.appearanceManager = appearance 103 | 104 | self.completionHandler = onCompletion 105 | self.cancelHandler = onCancel 106 | 107 | self.modalPresentationStyle = .overCurrentContext 108 | } 109 | 110 | required init?(coder aDecoder: NSCoder) { 111 | fatalError("init(coder:) has not been implemented") 112 | } 113 | 114 | func show(withAnimation animationType:YBTextPickerAnimation){ 115 | self.animation = animationType 116 | if let topController = UIApplication.topViewController() { 117 | var shouldAnimate = false 118 | if animation == .FromBottom{ 119 | shouldAnimate = true 120 | } 121 | topController.present(self, animated: shouldAnimate, completion: nil) 122 | } 123 | } 124 | 125 | override func viewDidLoad() { 126 | super.viewDidLoad() 127 | 128 | setupLayout() 129 | } 130 | 131 | override func viewDidAppear(_ animated: Bool) { 132 | super.viewDidAppear(animated) 133 | UIView.animate(withDuration: animationDuration, animations: { 134 | self.shadowView.backgroundColor = self.shadowColor.withAlphaComponent(self.shadowAmount) 135 | 136 | if self.animation == .Fade{ 137 | self.containerView.alpha = 1 138 | } 139 | 140 | }) 141 | } 142 | 143 | func setupLayout(){ 144 | tableView.register(UINib.init(nibName: "YBTextPickerCell", bundle: nil), forCellReuseIdentifier: "YBTextPickerCell") 145 | 146 | if animation == .Fade{ 147 | containerView.alpha = 0 148 | } 149 | 150 | containerView.layer.masksToBounds = true 151 | containerView.layer.cornerRadius = 5 152 | 153 | selectedValues = arrAllValues.filter{ 154 | preSelectedValues.contains($0.title) 155 | } 156 | 157 | tapToDismissGesture.isEnabled = tapToDismiss 158 | 159 | if let appearance = self.appearanceManager{ 160 | if let pTitle = appearance.pickerTitle{ 161 | titleLabel.text = pTitle 162 | } 163 | 164 | if let tFont = appearance.titleFont{ 165 | titleLabel.font = tFont 166 | } 167 | 168 | if let tBGColor = appearance.titleBackground{ 169 | titleLabel.backgroundColor = tBGColor 170 | } 171 | 172 | if let tColor = appearance.titleTextColor{ 173 | titleLabel.textColor = tColor 174 | } 175 | 176 | if let sFont = appearance.searchBarFont{ 177 | if let textFieldInsideSearchBar = txtSearch.value(forKey: "searchField") as? UITextField{ 178 | textFieldInsideSearchBar.font = sFont 179 | } 180 | } 181 | 182 | if let sPlaceholder = appearance.searchBarPlaceholder{ 183 | txtSearch.placeholder = sPlaceholder 184 | } 185 | 186 | if let cBtnTitle = appearance.closeButtonTitle{ 187 | btnClose.setTitle(cBtnTitle, for: .normal) 188 | } 189 | 190 | if let cBtnColor = appearance.closeButtonColor{ 191 | btnClose.setTitleColor(cBtnColor, for: .normal) 192 | } 193 | 194 | if let cBtnFont = appearance.closeButtonFont{ 195 | btnClose.titleLabel?.font = cBtnFont 196 | } 197 | 198 | if let dBtnTitle = appearance.doneButtonTitle{ 199 | btnDone.setTitle(dBtnTitle, for: .normal) 200 | } 201 | 202 | if let dBtnColor = appearance.doneButtonColor{ 203 | btnDone.setTitleColor(dBtnColor, for: .normal) 204 | } 205 | 206 | if let dBtnFont = appearance.doneButtonFont{ 207 | btnDone.titleLabel?.font = dBtnFont 208 | } 209 | } 210 | 211 | let deviceIdiom = UIScreen.main.traitCollection.userInterfaceIdiom 212 | 213 | switch (deviceIdiom) { 214 | case .pad: 215 | paddingToTop.constant = 190 216 | paddingToBottom.constant = 180 217 | paddingToLeft.constant = 135 218 | paddingToRight.constant = 135 219 | case .phone: 220 | paddingToTop.constant = 50 221 | paddingToBottom.constant = 60 222 | paddingToLeft.constant = 16 223 | paddingToRight.constant = 16 224 | case .tv: 225 | print("tvOS style UI") 226 | default: 227 | print("Unspecified UI idiom") 228 | } 229 | } 230 | 231 | //MARK:- Button Clicks 232 | @IBAction func closeAction(_ sender: Any) { 233 | cancelHandler?() 234 | closePicker() 235 | } 236 | 237 | @IBAction func doneAction(_ sender: Any) { 238 | 239 | let indexes = selectedValues.map{$0.identity!} 240 | let values = selectedValues.map{$0.title!} 241 | completionHandler?(indexes, values) 242 | 243 | closePicker() 244 | } 245 | 246 | func closePicker(){ 247 | UIView.animate(withDuration: animationDuration, animations: { 248 | self.shadowView.backgroundColor = .clear 249 | 250 | if self.animation == .Fade{ 251 | self.containerView.alpha = 0 252 | } 253 | 254 | }) { (completed) in 255 | self.presentingViewController?.dismiss(animated: true, completion: nil) 256 | } 257 | } 258 | 259 | } 260 | 261 | extension YBTextPicker : UISearchBarDelegate{ 262 | 263 | func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String) { 264 | if searchText.count == 0{ 265 | arrValues = arrAllValues.map{ $0 } 266 | }else{ 267 | 268 | arrValues = arrAllValues.filter{ 269 | $0.title.lowercased().contains(searchText.lowercased()) 270 | } 271 | 272 | } 273 | tableView.reloadData() 274 | } 275 | 276 | func searchBarSearchButtonClicked(_ searchBar: UISearchBar) { 277 | view.endEditing(true) 278 | } 279 | 280 | } 281 | 282 | extension YBTextPicker : UITableViewDataSource, UITableViewDelegate{ 283 | 284 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 285 | let cell = tableView.dequeueReusableCell(withIdentifier: "YBTextPickerCell", for: indexPath) as! YBTextPickerCell 286 | 287 | let dataModel = arrValues[indexPath.row] 288 | 289 | 290 | cell.lblItem.text = dataModel.title 291 | 292 | var chkImage:UIImage? = nil 293 | 294 | if selectedValues.contains(dataModel) 295 | { 296 | chkImage = #imageLiteral(resourceName: "YBTextPicker_checked.png") 297 | }else{ 298 | chkImage = #imageLiteral(resourceName: "YBTextPicker_unchecked.png") 299 | } 300 | 301 | cell.widthOfImgTrailingCheck.constant = 0.0 302 | 303 | if let appearance = self.appearanceManager{ 304 | if let itFont = appearance.itemFont{ 305 | cell.lblItem.font = itFont 306 | } 307 | if let itColor = appearance.itemColor{ 308 | cell.lblItem.textColor = itColor 309 | } 310 | 311 | if let itCheckedImage = appearance.itemCheckedImage{ 312 | if selectedValues.contains(dataModel) 313 | { 314 | chkImage = itCheckedImage 315 | } 316 | } 317 | if let itUncheckedImage = appearance.itemUncheckedImage{ 318 | if selectedValues.contains(dataModel) == false 319 | { 320 | chkImage = itUncheckedImage 321 | } 322 | } 323 | if let checkMarkPosition = appearance.checkMarkPosition{ 324 | let checkMarkWidth:CGFloat = 26.0 325 | if checkMarkPosition == .Right{ 326 | cell.widthOfImgTrailingCheck.constant = checkMarkWidth 327 | cell.widthOfImgLeadingCheck.constant = 0 328 | }else{ 329 | cell.widthOfImgLeadingCheck.constant = checkMarkWidth 330 | cell.widthOfImgTrailingCheck.constant = 0 331 | } 332 | } 333 | } 334 | 335 | cell.imgTrailingCheck.image = chkImage 336 | cell.imgLeadingCheck.image = chkImage 337 | 338 | return cell 339 | } 340 | 341 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 342 | return arrValues.count 343 | } 344 | 345 | func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 346 | if allowMultipleSelection == false { 347 | selectedValues = [YBTextPickerDataModel]() 348 | } 349 | 350 | let dataModel = arrValues[indexPath.row] 351 | if selectedValues.contains(dataModel){ 352 | selectedValues.removeAll{ $0 == dataModel } 353 | }else{ 354 | selectedValues.append(dataModel) 355 | } 356 | 357 | var cellsToReload = [IndexPath]() 358 | if allowMultipleSelection == false { 359 | cellsToReload = tableView.indexPathsForVisibleRows! 360 | //RELOAD ALL VISIBLE CELLS SO THAT PREVIOUSLY SELECTED CELL GETS DE-SELECTED 361 | }else{ 362 | cellsToReload = [indexPath] 363 | //SELECT OR DE-SELECT CURRENT CELL (NO NEED TO RELOAD OTHER CELLS) 364 | } 365 | tableView.reloadRows(at: cellsToReload, with: .fade) 366 | } 367 | 368 | } 369 | 370 | extension UIApplication { 371 | class func topViewController(controller: UIViewController? = UIApplication.shared.keyWindow?.rootViewController) -> UIViewController? { 372 | if let navigationController = controller as? UINavigationController { 373 | return topViewController(controller: navigationController.visibleViewController) 374 | } 375 | if let tabController = controller as? UITabBarController { 376 | if let selected = tabController.selectedViewController { 377 | return topViewController(controller: selected) 378 | } 379 | } 380 | if let presented = controller?.presentedViewController { 381 | return topViewController(controller: presented) 382 | } 383 | return controller 384 | } 385 | } 386 | -------------------------------------------------------------------------------- /YBTextPicker/YBTextPicker/YBTextPicker.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 87 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | -------------------------------------------------------------------------------- /YBTextPicker/YBTextPicker/YBTextPickerCell/YBTextPickerCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // YBTextPickerCell.swift 3 | // YBTextPicker 4 | // 5 | // Created by Yahya on 01/07/18. 6 | // Copyright © 2018 Yahya. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class YBTextPickerCell: UITableViewCell { 12 | 13 | @IBOutlet weak var lblItem: UILabel! 14 | 15 | @IBOutlet weak var imgLeadingCheck: UIImageView! 16 | @IBOutlet weak var widthOfImgLeadingCheck: NSLayoutConstraint! 17 | 18 | @IBOutlet weak var imgTrailingCheck: UIImageView! 19 | @IBOutlet weak var widthOfImgTrailingCheck: NSLayoutConstraint! 20 | 21 | override func awakeFromNib() { 22 | super.awakeFromNib() 23 | } 24 | 25 | override func setSelected(_ selected: Bool, animated: Bool) { 26 | super.setSelected(selected, animated: animated) 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /YBTextPicker/YBTextPicker/YBTextPickerCell/YBTextPickerCell.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /YBTextPicker/YBTextPicker/YBTextPickerDataModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // YBTextPickerDataModel.swift 3 | // YBTextPicker 4 | // 5 | // Created by Yahya Bagia on 14/03/19. 6 | // Copyright © 2019 Yahya. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class YBTextPickerDataModel : NSObject{ 12 | 13 | var title : String! 14 | var identity : Int! 15 | 16 | init(_ title:String, _ identity:Int) { 17 | super.init() 18 | self.title = title 19 | self.identity = identity 20 | } 21 | 22 | } 23 | --------------------------------------------------------------------------------