CocoaPods trunk is moving to be read-only. Read more on the blog, there are 12 months to go.
| TestsTested | ✗ |
| LangLanguage | SwiftSwift |
| License | MIT |
| ReleasedLast Release | Aug 2017 |
| SwiftSwift Version | 3.0 |
| SPMSupports SPM | ✗ |
Maintained by Kevin Wong.
Swiftuna is a decorator library that lets any view have a cool swipe-to-reveal options menu.
The example’s source code can be found in the SwiftunaExample project.
Swiftuna.xcodeproj as a subproject of your main project.Swiftuna.framework as an embedded framework.Then, to use, import the Swiftuna framework:
import SwiftunaIn order to decorate a view, the first thing to do is to instantiate a Swiftuna instance, which is the main decorator class. This class is in charge of doing all the configuration, so any custom attributes must be configured here. The configuration of each option in the menu is done separately in the SwiftunaOption class.
First, define an array of SwiftunaOptions to use:
let options = [
SwiftunaOption(image: UIImage(named: "Up")!),
SwiftunaOption(image: UIImage(named: "Down")!)
]Each option is initialized with an image, which is what will be displayed in the menu. You can additionally change the value of the size property in each SwiftunaOption object.
The next step is to attach the menu to a view. The short version:
Swiftuna(targetView: anyView, options: options).attach()If you want to customize the menu a bit, do it before the configuration is attached:
let swiftuna = Swiftuna(targetView: anyView, options: options)
swiftuna.optionsSpacing = 20
swiftuna.backgroundViewColor = UIColor.whiteColor()
swiftuna.attach()In order to react to certain events (for example, when an option is selected), the listening class must implement the SwiftunaDelegate protocol:
class MainController: SwiftunaDelegate {
...
let swiftuna = Swiftuna(targetView: anyView, options: options)
swiftuna.delegate = selfThen that class must implement the following method:
func swiftuna(swiftuna: Swiftuna, didSelectOption option: SwiftunaOption, index: Int)And optionally implement:
func swiftuna(swiftuna : Swiftuna, shouldDismissAfterSelectionOfOption option : SwiftunaOption, index : Int) -> BoolComments and suggestions much welcome
Kevin Wong, @kevinwl02
Code distributed under the MIT license