Rotating circle menu written in Swift 3

Overview

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!

You might also like...
ExpandingMenu is menu button for iOS written in Swift.
ExpandingMenu is menu button for iOS written in Swift.

ExpandingMenu ExpandingMenu is written in Swift. Requirements iOS 8.0+ Xcode 10.0+ Swift 3.x+ Installation CocoaPods You can install CocoaPods with th

Animated top menu for UITableView / UICollectionView / UIScrollView written in Swift
Animated top menu for UITableView / UICollectionView / UIScrollView written in Swift

Persei Animated top menu for UITableView / UICollectionView / UIScrollView written in Swift! Made in Yalantis. Check this project on Dribbble Check th

A side menu controller written in Swift for iOS
A side menu controller written in Swift for iOS

Description SideMenuController is a custom container view controller written in Swift which will display the main content within a center panel and th

UIKit drop down menu, simple yet flexible and written in Swift
UIKit drop down menu, simple yet flexible and written in Swift

DropDownMenuKit DropDownMenuKit is a custom UIKit control to show a menu attached to the navigation bar or toolbar. The menu appears with a sliding an

Menu controller with expandable item groups, custom position and appearance animation written with Swift. Similar to ActionSheet style of UIAlertController.
Menu controller with expandable item groups, custom position and appearance animation written with Swift. Similar to ActionSheet style of UIAlertController.

Easy to implement controller with expanding menu items. Design is very similar to iOS native ActionSheet presentation style of a UIAlertController. As

Beautiful iOS side menu library with parallax effect. Written in Swift
Beautiful iOS side menu library with parallax effect. Written in Swift

AKSideMenu AKSideMenu is a double side menu library with parallax effect. Example Project See the contained examples to get a sample of how AKSideMenu

iOS Slide Menu Controller. It is written in pure swift.
iOS Slide Menu Controller. It is written in pure swift.

SlideMenuController Requirements iOS 9+ Installation SlideMenuController is available through CocoaPods. To install it, simply add the following line

adb-tools-mac is a macOS menu bar app written in SwiftUI for common adb tools.
adb-tools-mac is a macOS menu bar app written in SwiftUI for common adb tools.

adb-tools-mac is a macOS menu bar app written in SwiftUI for common adb tools.

A simple customizable side menu written in SwiftUI.
A simple customizable side menu written in SwiftUI.

NSideMenu Description A simple customizable side menu written in SwiftUI. Give a Star! ⭐ Feel free to request an issue on github if you find bugs or r

Comments
  • Is there any way to support swift 2.3?

    Is there any way to support swift 2.3?

    First of all, thanks for offering your knowledge. I have been searching such feature for a long day with failure until I found yours. Easy to learn cause this was in SWIFT!!!. I looked raywenderlich tutorials and other libraries. Everything is in Objective C. Special Thanks to you.

    But, since my project is currently running on Xcode 7.3.1, can you make your project in Swift 2.3? iOS 8 support?

    opened by thihaaung6245 2
  • How to rotate the circle icons to keep them upright while the circle moves?

    How to rotate the circle icons to keep them upright while the circle moves?

    I would like to know how I can keep the icons inside the circle in an upright position, whether the circle moves and changes position, as in the initial position. A great job with the library, Thank you!

    opened by jaag12 1
  • Move to custom index?

    Move to custom index?

    Actually I am trying to create spinning wheel(eg. wheel of fortune) feature which will rotate at first until the results comes from the server. What I want was.

    Question 1 : How do we rotate the wheel without using gesture. Question 2 : How do we stop at specific index?

    it will be a lot helpful if you can help me with this.

    opened by thihaaung6245 0
Owner
Shoaib Ahmed
Blockchain | IoT | Embedded | Crypto - A software developer, urdu Sufi poet and self-proclaimed philosopher. 'Sufi-Al-Hussaini' is my nom-de-plume.
Shoaib Ahmed
A Slide Menu, written in Swift, inspired by Slide Menu Material Design

Swift-Slide-Menu (Material Design Inspired) A Slide Menu, written in Swift 2, inspired by Navigation Drawer on Material Design (inspired by Google Mat

Boisney Philippe 90 Oct 17, 2020
Swift-sidebar-menu-example - Create amazing sidebar menu with animation using swift

 SWIFT SIDEBAR MENU EXAMPLE In this project I create a awesome side bar menu fo

Paolo Prodossimo Lopes 4 Jul 25, 2022
Slide-Menu - A Simple Slide Menu With Swift

Slide Menu!! Весь интерфейс создан через код

Kirill 0 Jan 8, 2022
SwiftySideMenu is a lightweight and easy to use side menu controller to add left menu and center view controllers with scale animation based on Pop framework.

SwiftySideMenu SwiftySideMenu is a lightweight, fully customizable, and easy to use controller to add left menu and center view controllers with scale

Hossam Ghareeb 84 Feb 4, 2022
EasyMenu - SwiftUI Menu but not only button (similar to the native Menu)

EasyMenu SwiftUI Menu but not only button (similar to the native Menu) You can c

null 10 Oct 7, 2022
Hamburger Menu Button - A hamburger menu button with full customization

Hamburger Menu Button A hamburger menu button with full customization. Inspired by VinhLe's idea on the Dribble How to use it You can config the looks

Toan Nguyen 114 Jun 12, 2022
A simple side menu for iOS written in Swift.

ENSwiftSideMenu A lightweight flyover side menu component for iOS with the UIDynamic's bouncing animation, UIGestures and UIBlurEffect. Allows you to

Evgeny Nazarov 1.8k Dec 21, 2022
iOS Interactive Side Menu written in Swift.

Interactive Side Menu A customizable, interactive, auto expanding and collapsing side menu for iOS written in Swift. Here are some of the ways Interac

Handsome 706 Dec 15, 2022
iOS Slide Menu View based on Google+, iQON, Feedly, Ameba iOS app. It is written in pure swift.

SlideMenuControllerSwift iOS Slide View based on iQON, Feedly, Google+, Ameba iPhone app. Installation CocoaPods pod 'SlideMenuControllerSwift' Carth

Yuji Hato 3.3k Dec 29, 2022
The elegant yet functional dropdown menu, written in Swift, appears underneath the navigation bar to display a list of defined items when a user clicks on the navigation title.

Introduction The elegant yet functional dropdown menu, written in Swift, appears underneath the navigation bar to display a list of defined items when

Tho Pham 2.7k Dec 28, 2022