Expand circular menu by giving only instance of the menu buttons.
- 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"
ASExtendedCircularMenu is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod ‘ASExtendedCircularMenu’, :git => 'https://github.com/anshul18895/ASExtendedCircularMenu'
To set how menu should expand.(options: topLeft,topCenter...)
To set radius of expanded menu.
For number of items in menu.
For adding or removing animation of button.
Size of menu button (options: small,medium,large)
For making Button Draggable.
1. Create button in interface builder. And give it class ASCircularMenu
and module ASExtendedCircularMenu
. And create referencing outlet in viewController class.
2. Extend viewController class with ASCircularButtonDelegate
. and configure button in viewDidLoad()
.
There are three ways to configure button. 1) static 2) Dynamic 3) Draggable
configureCircularMenuButton(button: colourPickerButton, numberOfMenuItems: 5, menuRedius: 70, postion: .bottomLeft)
configureDynamicCircularMenuButton(button: colourPickerButton, numberOfMenuItems: 5)
configureDraggebleCircularMenuButton(button: colourPickerButton, numberOfMenuItems: 8, menuRedius: 70, postion: .center)
3. Call following two protocol methods and Return button in buttonForIndexAt()
for index in menu and set target for menu button using didClickOnCircularMenuButton()
.
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
}
func didClickOnCircularMenuButton(_ menuButton: ASCircularMenuButton, indexForButton: Int, button: UIButton) {
if menuButton == colourPickerButton{
self.viewLbl.textColor = button.backgroundColor
}
}
To run the example project, clone the repo, and run pod install
from the Example directory first.
anshul18895, [email protected]
ASExtendedCircularMenu is available under the MIT license. See the LICENSE file for more info.