TestsTested | ✓ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Jun 2016 |
SPMSupports SPM | ✗ |
Maintained by Mateusz Fidos.
To run the example project, clone the repo, open and run Example scheme.
ARC
iOS8
MFCircleDialPad is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "MFCircleDialPad"
Start with some importing:
import MFCircleDialPad
Define and customize items:
You can build items with custom text, bgColor, image or size.
var items:[MFDialPadItem] = []
for idx in 0..<10
{
items.append(MFDialPadItem(text: "\(idx)", backgroundColor: nil, image: nil, radius: 60))
}
Same goes to center item:
let centerItem = MFDialPadCenterItem(backgroundColor: UIColor.clearColor(), image: nil, radius: 80)
If you want to you can define some additional assets for when dial pad changes state (value) so your center item can have more than one image (there are already some assets in the pod that you can use - see example)
centerItem.setImageForState(UIImage(named: "phonecallarrow")!, state: MFDialPadItemState.MFDialPadItemStateDefault)
centerItem.setImageForState(UIImage(named: "phonecallgreen")!, state: MFDialPadItemState.MFDialPadItemStateValid)
centerItem.setImageForState(UIImage(named: "phonecallred")!, state: MFDialPadItemState.MFDialPadItemStateInvalid)
So everytime this delegate method gets called:
public protocol MFDialPadControlDelegate
{
func dialPadDidChangeValue(value:Int)
}
you can check if number you’ve chosen is actually a valid phone number:
func dialPadDidChangeValue(value: Int)
{
self.numberField.text = self.numberField.text?.stringByAppendingString("\(value)")
self.control.updateCenterItemIfValid(self.numberField.text!)
}
Also you can conform to
MFDialPadOrientationHandlerDelegate
to receive notifications everytime orientation changes
func orientationDidChange(orientation: UIDeviceOrientation)
{
self.control.center = self.view.center
self.control.updatePosition()
}
This method helps pad control to adjust its size or radius when there is not enough space to draw and collision is detected
self.control.updatePosition()
Inspired by: https://github.com/Ramotion/circle-menu
Mateusz Fidos, [email protected]
MFCircleDialPad is available under the MIT license. See the LICENSE file for more info.