MFCircleDialPad 0.1.1

MFCircleDialPad 0.1.1

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Jun 2016
SPMSupports SPM

Maintained by Mateusz Fidos.



MFCircleDialPad

Example

To run the example project, clone the repo, open and run Example scheme.

Requirements

ARC
iOS8

Installation

MFCircleDialPad is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "MFCircleDialPad"

Usage

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()

Note:

Inspired by: https://github.com/Ramotion/circle-menu

Author

Mateusz Fidos, [email protected]

License

MFCircleDialPad is available under the MIT license. See the LICENSE file for more info.