Skip to content

Instantly share code, notes, and snippets.

View etolstoy's full-sized avatar
🥦

Egor Tolstoy etolstoy

🥦
View GitHub Profile
@etolstoy
etolstoy / fma
Last active August 29, 2015 13:55
Footer Menu Animation
- (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;
@etolstoy
etolstoy / CEViewController.m
Created March 2, 2014 17:27
customcontrol-1
#import "CERangeSlider.h"
@etolstoy
etolstoy / CEViewController.m
Created March 2, 2014 17:28
customcontrol-2
@implementation CEViewController
{
CERangeSlider* _rangeSlider;
}
@etolstoy
etolstoy / CEViewController.m
Created March 2, 2014 17:29
customcontrol-3
- (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];
@etolstoy
etolstoy / CERangeSlider.h
Created March 2, 2014 17:31
customcontrol-4
@property (nonatomic) float maximumValue;
@property (nonatomic) float minimumValue;
@property (nonatomic) float upperValue;
@property (nonatomic) float lowerValue;
@etolstoy
etolstoy / CERangeSlider.m
Last active August 29, 2015 13:56
customcontrol-5
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
_maximumValue = 10.0;
_minimumValue = 0.0;
_upperValue = 8.0;
_lowerValue = 2.0;
}
@etolstoy
etolstoy / CERangeSlider.m
Created March 2, 2014 17:34
customcontrol-6
#import <QuartzCore/QuartzCore.h>
@etolstoy
etolstoy / CERangeSlider.m
Created March 2, 2014 17:35
customcontrol-7
@implementation CERangeSlider
{
CALayer* _trackLayer;
CALayer* _upperKnobLayer;
CALayer* _lowerKnobLayer;
float _knobWidth;
float _useableTrackLength;
}
@etolstoy
etolstoy / CERangeSlider.m
Created March 2, 2014 17:35
customcontrol-8
_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;
@etolstoy
etolstoy / CERangeSlider.m
Created March 2, 2014 17:36
customcontrol-8
- (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);