Skip to content

Commit

Permalink
allow shadow color to be changed
Browse files Browse the repository at this point in the history
  • Loading branch information
bvogelzang committed Jun 16, 2013
1 parent dd4f0f3 commit 1f7f090
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions SevenSwitch.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
@property (nonatomic, strong) UIColor *onColor;
@property (nonatomic, strong) UIColor *borderColor;
@property (nonatomic, strong) UIColor *knobColor;
@property (nonatomic, strong) UIColor *shadowColor;

- (void)setOn:(BOOL)on animated:(BOOL)animated;

Expand Down
10 changes: 8 additions & 2 deletions SevenSwitch.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ - (void)showOff:(BOOL)animated;

@implementation SevenSwitch

@synthesize inactiveColor, activeColor, onColor, borderColor, knobColor, on;
@synthesize inactiveColor, activeColor, onColor, borderColor, knobColor, shadowColor, on;

- (id)initWithFrame:(CGRect)frame
{
Expand All @@ -53,6 +53,7 @@ - (id)initWithFrame:(CGRect)frame
self.onColor = [UIColor colorWithRed:0.30f green:0.85f blue:0.39f alpha:1.00f];
self.borderColor = [UIColor colorWithRed:0.89f green:0.89f blue:0.91f alpha:1.00f];
self.knobColor = [UIColor whiteColor];
self.shadowColor = [UIColor grayColor];

// background
background = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 50, 30)];
Expand All @@ -67,7 +68,7 @@ - (id)initWithFrame:(CGRect)frame
knob = [[UIView alloc] initWithFrame:CGRectMake(1, 1, 28, 28)];
knob.backgroundColor = self.knobColor;
knob.layer.cornerRadius = 14.0;
knob.layer.shadowColor = [UIColor grayColor].CGColor;
knob.layer.shadowColor = self.shadowColor.CGColor;
knob.layer.shadowRadius = 2.0;
knob.layer.shadowOpacity = 0.5;
knob.layer.shadowOffset = CGSizeMake(0, 3);
Expand Down Expand Up @@ -174,6 +175,11 @@ - (void)setKnobColor:(UIColor *)color {
knob.backgroundColor = color;
}

- (void)setShadowColor:(UIColor *)color {
shadowColor = color;
knob.layer.shadowColor = color.CGColor;
}

/*
* set (without animation) whether the switch is ON or OFF
*/
Expand Down

0 comments on commit 1f7f090

Please sign in to comment.