iOSComboBox is a customizable combo box (drop-down) view for iOS, designed to provide a simple way to integrate a selection interface into your apps.
- Customizable appearance
- Supports both static and dynamic data
- Smooth animations for the dropdown
- Easy integration with both Storyboard and programmatically
- Swift and Objective-C compatibility
- iOS 12.0+v
- Swift 5.0+
- Xcode 12.0+
iOSComboBox supports installation via Swift Package Manager, which is built into Xcode.
- In Xcode, select File > Add Packages...
- Paste the repository URL into the search field:
https://github.com/rojarand/iOSComboBox.git
- Select the version or branch you want to use.
- Click Add Package to add it to your project.
To integrate iOSComboBox using CocoaPods, follow these steps:
- Add iOSComboBox to your
Podfile
:
pod 'iOSComboBox', '~> 0.0.3'
- Install the pod by running the following command in your terminal:
[bundle exec] pod install
- Open your project via the generated
.xcworkspace
file.
Here's an example of how to use iOSComboBox programmatically:
import iOSComboBox
let comboBox = iOSComboBox(frame: CGRect(x: 20, y: 100, width: 280, height: 40))
comboBox.items = ["Option 1", "Option 2", "Option 3"]
comboBox.placeholder = "Select an option"
comboBox.onSelectionChanged = { selectedItem in
print("Selected: \(selectedItem)")
}
self.view.addSubview(comboBox)
- Drag a UIView onto your storyboard.
- Set its class to iOSComboBox in the Identity Inspector.
- Configure the control's properties in the Attributes Inspector or programmatically.
@IBOutlet weak var comboBox: iOSComboBox!
override func viewDidLoad() {
super.viewDidLoad()
comboBox.items = ["Item 1", "Item 2", "Item 3"]
comboBox.onSelectionChanged = { selectedItem in
print("Selected item: \(selectedItem)")
}
}
iOSComboBox allows you to customize various aspects of the control:
Items: Set the items in the dropdown using the items
property.
Placeholder: Set placeholder text using the placeholder
property.
Dropdown Appearance: Customize the dropdown's height, font, and colors.
Selection Callback: Use the onSelectionChanged
closure to handle selection changes.
To explore a full example, check out the iOSComboBoxApp folder in this repository, which demonstrates how to integrate and use iOSComboBox in various scenarios.
iOSComboBox is released under the MIT license. See LICENSE for details.