A simple popup menu/selector control for iOS 8 and above.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
KFPopupSelector.xcodeproj
KFPopupSelector
KFPopupSelectorTests
Default-568h@2x.png
LICENSE
README.md

README.md

KFPopupSelector

KFPopupSelector is a Cocoa Touch control which presents a simple popup menu containing several string options. Its features are:

  • Written in Swift, using modern Swift language features.

  • Is entirely encapsulated in a UIControl subclass, and designed to be used in Storyboards. Emits a valueChanged event when the value changes.

  • Handling of button label is configurable; can be fixed or changed to selected value, and can optionally be decorated with a downward triangle.

There is more information on the design and implementation of this control here.

Example

A simple example of using KFPopupSelector:

class MyViewController : UIViewController {

    // KFPopupSelector is added in the Storyboard and linked here.
    @IBOutlet var popup: KFPopupSelector!

    override func viewDidLoad() {
        super.viewDidLoad()
        // configure the KFPopupSelector's options

        popup.options = [ .Text(text:"Red"), .Text(text:"Green"), .Text(text:"Blue") ]
        popup.labelDecoration = .DownwardTriangle
        popup.unselectedLabelText = "Please pick a colour"
    }

    // This method is wired to the KFPopupSelector's valueChanged message in the Storyboard
    @IBAction func popupChanged(sender: AnyObject!) {
        println("You selected option number \(popup.selectedIndex!)")
    }
}

Using KFPopupSelector in your own projects

KFPopupSelector is entirely encapsulated in one source file, KFPopupSelector.swift; simply add this to your project and use.

KFPopupSelector is licenced under the MIT Licence.