TestsTested | ✓ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | May 2016 |
SPMSupports SPM | ✗ |
Maintained by Mateusz Fidos.
To run the example project, clone the repo, open and run Example scheme.
ARC
iOS8
MFCircleMenu is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "MFCircleMenu"
Now you can define wheter you want your menu to adjust to your devices orientation. There is a new property in initializer method:
adjustToOrientation:Bool
Setting this property to be true
will automatically adjust your “other items” to be laid out accordingly to orientation of your device. Setting this to be false
will prevent rotation and adjusting.
NOTE: Even if you set this property to be false
if there are too many elements in menu and collision will be detected after roatation, items position will be changed to prevent from colliding with screens edge.
import MFCircleMenu
Item action definition:
let mainAction: MainItemActionClosure = {
if (self.menu.menuState == .Closed)
{
self.presenter.openMenu()
}
else
{
self.presenter.closeMenu()
}
}
let itemOneAction: ItemActionClosure = {
print("Item One tapped")
let controller = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("nextViewController")
self.presentViewController(controller, animated: true, completion: nil)
}
let itemTwoAction: ItemActionClosure = {
print("Item Two tapped")
}
Create menu items: (You can also use convenience initializers for items - some values are optional)
let mainCircle = MFCircleMenuMainItem(action: mainAction, closedStateImage: UIImage(named: "settings")!, openedStateImage: UIImage(named: "soundon")!, text: nil, backgroundColor: UIColor.redColor())
let itemOne = MFCircleMenuOtherItem(action: itemOneAction, image: UIImage(named: "soundon")!, text: "Item One", backgroundColor: nil)
let itemTwo = MFCircleMenuOtherItem(action: itemTwoAction, image: UIImage(named: "soundoff")!, text: nil, backgroundColor: UIColor.blueColor())
Create menu component and define position on screen where you want menu to show up
let menu = MFCircleMenu(mainItem: mainCircle, otherItems: [itemOne, itemTwo], parent: self.view, adjustToOrientation: false)
menu.showAtPosition(MFCircleMenuPosition.TopLeft)
This is still WIP
UITests to be added soon
Mateusz Fidos, [email protected]
MFCircleMenu is available under the MIT license. See the LICENSE file for more info.