Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lm2343635/mgselector
A customized table selector for iOS.
https://github.com/lm2343635/mgselector
Last synced: about 1 month ago
JSON representation
A customized table selector for iOS.
- Host: GitHub
- URL: https://github.com/lm2343635/mgselector
- Owner: lm2343635
- License: mit
- Created: 2018-10-01T02:02:01.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-12-22T13:42:35.000Z (11 months ago)
- Last Synced: 2024-04-23T02:07:22.144Z (7 months ago)
- Language: Swift
- Homepage:
- Size: 324 KB
- Stars: 6
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MGSelector
![Swift 5.1](https://img.shields.io/badge/Swift-5.1-orange.svg)
[![CI Status](https://img.shields.io/travis/lm2343635/MGSelector.svg?style=flat)](https://travis-ci.org/lm2343635/MGSelector)
[![Version](https://img.shields.io/cocoapods/v/MGSelector.svg?style=flat)](https://cocoapods.org/pods/MGSelector)
[![License](https://img.shields.io/cocoapods/l/MGSelector.svg?style=flat)](https://cocoapods.org/pods/MGSelector)
[![Platform](https://img.shields.io/cocoapods/p/MGSelector.svg?style=flat)](https://cocoapods.org/pods/MGSelector)MGSelector is a customised table selector for iOS.
## Example
To run the example project, clone the repo, and run `pod install` from the Example directory first.
## Installation
MGSelector is available through [CocoaPods](https://cocoapods.org). To install
it, simply add the following line to your Podfile:```ruby
pod 'MGSelector'
```## Documentation
Prepare your model which confirms the MGSelectorModel protocol at first.
```Swift
struct Option: MGSelectorOption {
var icon: UIImage?
var title: String
var tag: String?
var detail: String?
}
```
Confirm the MGSelectable protocol in your view controller, and invokes the `openSelector` method.```Swift
let options: [Options] = ...class ViewController: UIViewController, MGSelectable {
//...@IBAction func open(_ sender: UIButton) {
openSelector(title: "Title", options: options, mode: .single(selectedIndex: 0), theme: .dark)
}
func didSelect(options: [MGSelectorOption]) {
title = options.map { $0.title }.reduce("", +)
}
}
```Get the select result using the `didSelect` protocol method.
## Author
lm2343635, [email protected]
## License
MGSelector is available under the MIT license. See the LICENSE file for more info.