Latest 0.0.4
Homepage https://github.com/kevinwl02/Swiftuna
License MIT
Platforms ios 8.0, requires ARC
Authors

SwiftunaLogo

Swiftuna is a decorator library that lets any view have a cool swipe-to-reveal options menu.

Example

Swiftuna

The example’s source code can be found in the SwiftunaExample project.

Installation

Cocoapods:

Add this to your Podfile:

pod 'Swiftuna', '~> 0.0.4'

Manual installation:

  1. Add this repository as a git submodule of your project. (optional)
  2. Once you have downloaded the source, add the Swiftuna.xcodeproj as a subproject of your main project.
  3. In your main project’s General tab, add the Swiftuna.framework as an embedded framework.

Then, to use, import the Swiftuna framework:

import Swiftuna

Usage

In 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.

Adding the menu

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()

Reacting to events

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 = self

Then 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) -> Bool

Author

Comments and suggestions much welcome

Kevin Wong, @kevinwl02

License

Code distributed under the MIT license

Latest podspec

{
    "name": "Swiftuna",
    "version": "0.0.4",
    "summary": "Decorator library that lets any view have a cool swipe-to-reveal options menu",
    "homepage": "https://github.com/kevinwl02/Swiftuna",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Kevin Wong": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/kevinwl02/Swiftuna.git",
        "tag": "0.0.4"
    },
    "source_files": [
        "Swiftuna/Swiftuna/*.{swift,h,m}",
        "Swiftuna/Swiftuna/**/*.{swift,h,m}"
    ],
    "requires_arc": true,
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This