Popularity
2.9
Stable
Activity
0.0
Stable
123
5
15

Code Quality Rank: L3
Programming language: Swift
License: MIT License
Tags: UI     Menu    

Swift-CircleMenu alternatives and similar libraries

Based on the "Menu" category.
Alternatively, view Swift-CircleMenu alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of Swift-CircleMenu or a related project?

Add another 'Menu' Library

README

Swift-CircleMenu

A rotating circle menu written in Swift 3.

Features

  • Gesture based rotation
  • Configurable rotatability
  • High customisability
  • Simple intuitive API
  • Inertia effect
  • Ready to use samples

Screenshots

Swift-CircleMenu in action in CETUS iOS App.

simulator screen shot dec 3 2016 9 17 45 pm simulator screen shot dec 3 2016 9 17 30 pm

Getting Started

Add this to your Podfile:

pod 'Swift-CircleMenu', :git => 'https://github.com/Sufi-Al-Hussaini/Swift-CircleMenu.git'

Usage

Please look at the demo project provided.

Basically, you'll need to create a circle and setup its frame & positioning, and add it to your view. Optionally, you may add an overlay.

Don't forget to set the delegate and datasource.

class DefaultRotatingViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        prepareDefaultCircleMenu()
    }

    func prepareDefaultCircleMenu() {
        // Create circle
        let circle = Circle(with: CGRect(x: 10, y: 90, width: 300, height: 300), numberOfSegments: 10, ringWidth: 80.0)
        // Set dataSource and delegate
        circle.dataSource = self
        circle.delegate = self

        // Position and customize
        circle.center = view.center

        // Create overlay with circle
        let overlay = CircleOverlayView(with: circle)

        // Add to view
        self.view.addSubview(circle)
        self.view.addSubview(overlay!)
    }

}

Then, you need to conform to the CircleDelegate and CircleDataSource protocols by implementing the didMoveTo segment: and iconForThumbAt row: methods.


extension DefaultRotatingViewController: CircleDelegate, CircleDataSource {

    func circle(_ circle: Circle, didMoveTo segment: Int, thumb: CircleThumb) {
        let alert = UIAlertController(title: "Selected", message: "Item with tag: \(segment)", preferredStyle: UIAlertControllerStyle.alert)
        alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.cancel, handler: nil))
        self.present(alert, animated: true, completion: nil)
    }

    func circle(_ circle: Circle, iconForThumbAt row: Int) -> UIImage {
        return UIImage(named: "icon_arrow_up")!
    }

}

The above code will give you the default minimal circle menu shown below.

simulator screen shot dec 3 2016 9 12 50 pm

You can disable rotation using Circle's optional default constructor parameter isRotating like so:

let circle = Circle(with: CGRect(x: 10, y: 90, width: 300, height: 300), numberOfSegments: 10, ringWidth: 80.0, isRotating: false)

More examples to be added soon. :)

License

Swift-CircleMenu is licensed under the MIT license.

Why Swift-CircleMenu?

For an app I was developing recently, I wanted something like Android-CircleMenu, i.e. a rotatable circle menu. I came across a number of circle menus for iOS on github, but only one supported rotation with inertia effect - CDPieMenu. The problem with CDPieMenu though, is that it is written in Obj-C and isn't being maintained currently. So, I decided to rewrite CDPieMenu in swift and include in it all features I required in my app, and make it available publicly.

Credits

Swift-CircleMenu is (more than) heavily inspired by CDPieMenu - an Obj-C library written by Wojtek Czekalski. In its current form, this project is essentially a rewrite of CDPieMenu in Swift, with multiple bug-fixes and added features & examples. Special thanks to Wojtek Czekalski for his awesome CDPieMenu library!


*Note that all licence references and agreements mentioned in the Swift-CircleMenu README section above are relevant to that project's source code only.