A Rotary Wheel for altering content that can be customised in Interface Builder
Currently allows for up to 8 sectors in Interface Builder
Contact me at [email protected] if you want any more added functionality
- Rotates on a Timer until Wheel is touched
- Timer shuts off and then can be dragged or touched to spin the wheel
- Functionality for changing any content when wheel turns
- Background, number of elements and images can be changed in the Interface Builder
HCRotaryWheel is available through CocoaPods. To install it, simply add the following line to your Podfile:
use_frameworks!
pod 'HCRotaryWheel', '~> 1.1'
adding use_frameworks! allows for CocoaPods to parse IBDesignable elements
- Clone Project
- Build in Xcode for example project
- Drag Controls folder into your project
- Enter class in Identity Inspector
Edit in Attributes Inspector
In your ViewController.h drag your HCRotaryWheelView as an IBOutlet and add RotaryProtocol to call Delegate Methods
#import "HCRotaryWheel.h"
@interface ViewController : UIViewController <RotaryProtocol>
@property (weak, nonatomic) IBOutlet UILabel *textLabel;
@property (weak, nonatomic) IBOutlet HCRotaryWheelView *rotaryWheelView;
@end
In ViewController.m
- (void)viewDidLoad {
[super viewDidLoad];
//set view controller as delegate to Rotary Wheel
self.rotaryWheelView.delegate = self;
//set initial Text for a label or other content
self.textLabel.text = @"Bear";
}
// built in HCRotaryWheel Delegate Method
- (void) wheelDidChangeValue:(int)currentSector {
// change any text when wheel rotates, is tapped or dragged
self.textLabel.text = [self getDescriptionText:currentSector];
}
- (NSString *) getDescriptionText:(int)newValue {
NSString *text = @"";
switch(newValue) {
case 0:
text = @"Bear";
break;
case 1:
text = @"Monkey";
break;
case 2:
text = @"Dog";
break;
case 3:
text = @"Ghost";
break;
case 4:
text = @"Peace";
break;
case 5:
text = @"Alien";
break;
default:
break;
}
return text;
}
##How to use Swift
import UIKit
import HCRotaryWheel
class ViewController: UIViewController, RotaryProtocol {
@IBOutlet weak var textField: UITextField!
@IBOutlet weak var hcview: HCRotaryWheel!
override func viewDidLoad() {
super.viewDidLoad()
self.hcview.delegate = self
self.textField.text = "Bear"
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func wheelDidChangeValue(currentSector: Int32) {
self.textField.text = self.getDescriptionText(currentSector);
}
func getDescriptionText(newValue :Int32) -> String
{
switch newValue {
case 0:
return "Bear"
case 1:
return "Monkey"
case 2:
return "Dog"
case 3:
return "Ghost"
case 4:
return "Peace"
case 5:
return "Alien"
default:
return "Bear"
}
}
Hannah Carney, [email protected]
HCRotaryWheel is available under the MIT license. See the LICENSE file for more info.