Preview
Expand circular menu by giving only instance of the menu buttons.
Features
- Static Initialization (Static radius and static position) "Not Draggable"
- Dynamic Initialization (Automatic find dynamic radius and dynamic positions) "Not Draggable"
- Draggable Initialization (Automatic find dynamic radius and dynamic positions) "Draggable + Dynamic"
Installation
ASExtendedCircularMenu is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod ‘ASExtendedCircularMenu’, :git => 'https://github.com/anshul18895/ASExtendedCircularMenu'
Getting Started
Variables:
circularButtonPosition
1. To set how menu should expand.(options: topLeft,topCenter...)
menuRadius
2. To set radius of expanded menu.
numberOfMenuItem
3. For number of items in menu.
shouldMenuButtonAnimate
4. For adding or removing animation of button.
menuButtonSize
5. Size of menu button (options: small,medium,large)
isDraggable
6. For making Button Draggable.
Steps:
ASCircularMenu
and module ASExtendedCircularMenu
. And create referencing outlet in viewController class.
1. Create button in interface builder. And give it class
ASCircularButtonDelegate
. and configure button in viewDidLoad()
.
2. Extend viewController class with There are three ways to configure button. 1) static 2) Dynamic 3) Draggable
Static Initialization
configureCircularMenuButton(button: colourPickerButton, numberOfMenuItems: 5, menuRedius: 70, postion: .bottomLeft)
Dynamic Initialization
configureDynamicCircularMenuButton(button: colourPickerButton, numberOfMenuItems: 5)
Draggable Intialization
configureDraggebleCircularMenuButton(button: colourPickerButton, numberOfMenuItems: 8, menuRedius: 70, postion: .center)
buttonForIndexAt()
for index in menu and set target for menu button using didClickOnCircularMenuButton()
.
3. Call following two protocol methods and Return button in buttonForIndexAt()
method for returning button instance for index of menu.
Calling func buttonForIndexAt(_ menuButton: ASCircularMenuButton, indexForButton: Int) -> UIButton {
let button: UIButton = UIButton()
if menuButton == shareButton{
button.setBackgroundImage(UIImage.init(named: "shareicon.\(indexForButton + 1)"), for: .normal)
}
if menuButton == colourPickerButton{
button.backgroundColor = colourArray[indexForButton]
}
return button
}
didClickOnCircularMenuButton()
method for setting method call on click (Setting target).
Calling func didClickOnCircularMenuButton(_ menuButton: ASCircularMenuButton, indexForButton: Int, button: UIButton) {
if menuButton == colourPickerButton{
self.viewLbl.textColor = button.backgroundColor
}
}
Example
To run the example project, clone the repo, and run pod install
from the Example directory first.
Author
anshul18895, [email protected]
License
ASExtendedCircularMenu is available under the MIT license. See the LICENSE file for more info.