Introducing SMWheelControl

Today I am proud to announce the availability of a new Pod for iOS which will be included in my forthcoming app.

SMWheelControl

SMWheelControl is an iOS control allowing the selection of an item from a 360° spinning wheel with a smooth inertial rotation.

The code, released under the BSD 3-clause license, is loosely based on the tutorial “How To Create a Rotating Wheel Control with UIKit” published on this Ray Wenderlich’s post by Cesare Rocchi

As usual, you can insert it into your podfile by adding

Some howto follows.

Usage

Initialization and data source

Instantiate the control with a classical - (id)initWithFrame:(CGRect)rect and add a target as you usually do with a control, e.g.:

Then add a dataSource:

and implement the following methods (the dataSource should conform to the SMWheelControlDataSource):

For instance:

When the wheel ends snapping to the closest slice, if you added a target, then it will receive the event UIControlEventValueChanged, and the selector you specified will be executed.

  • Vinod

    Hello,

    I am using your wheel control SMWheelControl for my IOS . This library saved my time a lot.

    Initially I could create a wheel with five items in it. It works fine. ​​​​

    But when I added four more items some slices shows different width. (Now the wheel has total 9 elements).

    I have tried to change the values of frames inside the function viewForSliceAtIndex

    – (UIView *)wheel:(SMWheelControl *)wheel viewForSliceAtIndex:(NSUInteger)index

    {

    UIImage* sourceImage = segmentColorArray[index%9];

    // UIImageView* flippedImage = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 135, 130)]; // initial value for 5 elements

    UIImageView* flippedImage = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 160, 110)]; // new value for 9 elements

    flippedImage.contentMode = UIViewContentModeScaleToFill;

    flippedImage.clipsToBounds = YES;

    flippedImage.image = [UIImage imageWithCGImage:sourceImage.CGImage

    scale:sourceImage.scale

    orientation:UIImageOrientationUpMirrored];

    return flippedImage;

    }

    But now the wheel has lost it’s circle shape.

    I have also tried to change few values of the function drawWheel inside SMWheelControl.h. But no expected result.

    Please advice

    Best Regards,

    Vinod A