This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)showMenu | |
{ | |
CALayer* layer = _menuButtonImageView.layer; | |
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"]; | |
animation.fromValue = [NSNumber numberWithFloat:0.0 * M_PI]; | |
animation.toValue = [NSNumber numberWithFloat:1.0 * M_PI]; | |
animation.duration = 0.3; | |
animation.cumulative = YES; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "CERangeSlider.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@implementation CEViewController | |
{ | |
CERangeSlider* _rangeSlider; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)viewDidLoad | |
{ | |
[super viewDidLoad]; | |
// Do any additional setup after loading the view, typically from a nib. | |
NSUInteger margin = 20; | |
CGRect sliderFrame = CGRectMake(margin, margin, self.view.frame.size.width - margin * 2, 30); | |
_rangeSlider = [[CERangeSlider alloc] initWithFrame:sliderFrame]; | |
_rangeSlider.backgroundColor = [UIColor redColor]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@property (nonatomic) float maximumValue; | |
@property (nonatomic) float minimumValue; | |
@property (nonatomic) float upperValue; | |
@property (nonatomic) float lowerValue; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (id)initWithFrame:(CGRect)frame | |
{ | |
self = [super initWithFrame:frame]; | |
if (self) { | |
// Initialization code | |
_maximumValue = 10.0; | |
_minimumValue = 0.0; | |
_upperValue = 8.0; | |
_lowerValue = 2.0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <QuartzCore/QuartzCore.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@implementation CERangeSlider | |
{ | |
CALayer* _trackLayer; | |
CALayer* _upperKnobLayer; | |
CALayer* _lowerKnobLayer; | |
float _knobWidth; | |
float _useableTrackLength; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_trackLayer = [CALayer layer]; | |
_trackLayer.backgroundColor = [UIColor blueColor].CGColor; | |
[self.layer addSublayer:_trackLayer]; | |
_upperKnobLayer = [CALayer layer]; | |
_upperKnobLayer.backgroundColor = [UIColor greenColor].CGColor; | |
[self.layer addSublayer:_upperKnobLayer]; | |
_lowerKnobLayer = [CALayer layer]; | |
_lowerKnobLayer.backgroundColor = [UIColor greenColor].CGColor; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void) setLayerFrames | |
{ | |
_trackLayer.frame = CGRectInset(self.bounds, 0, self.bounds.size.height / 3.5); | |
[_trackLayer setNeedsDisplay]; | |
_knobWidth = self.bounds.size.height; | |
_useableTrackLength = self.bounds.size.width - _knobWidth; | |
float upperKnobCentre = [self positionForValue:_upperValue]; | |
_upperKnobLayer.frame = CGRectMake(upperKnobCentre - _knobWidth / 2, 0, _knobWidth, _knobWidth); |
OlderNewer