Skip to content

Commit

Permalink
Fix scroller outline. Switched to shadow from border.
Browse files Browse the repository at this point in the history
  • Loading branch information
avaidyam committed Oct 19, 2012
1 parent a733539 commit c3edfa0
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions lib/UIKit/TUIScroller.m
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,16 @@ - (id)initWithFrame:(CGRect)frame {
if((self = [super initWithFrame:frame])) {
_knob = [[TUIView alloc] initWithFrame:CGRectZero];
self.knob.userInteractionEnabled = NO;
self.knob.layer.borderWidth = 1.0f;
self.scrollIndicatorStyle = TUIScrollViewIndicatorStyleDefault;
self.knob.clipsToBounds = NO;

self.knob.layer.shadowColor = [NSColor whiteColor].tui_CGColor;
self.knob.layer.shadowOffset = CGSizeMake(0, 0);
self.knob.layer.shadowOpacity = 1.0;
self.knob.layer.shadowRadius = 1.0;

self.scrollIndicatorStyle = TUIScrollViewIndicatorStyleDefault;
[self addSubview:self.knob];

[self _updateKnob];
[self _updateKnobAlphaWithSpeed:0.0];

Expand Down Expand Up @@ -172,10 +178,10 @@ - (void)_updateKnob {
CGRect frame = CGRectZero;
if(self.vertical) {
frame = CGRectMake(0.0, knobOffset, self.updatedScrollerWidth, knobLength);
frame = ABRectRoundOrigin(CGRectInset(frame, 2, 4));
frame = CGRectIntegral(CGRectInset(frame, 2, 4));
} else {
frame = CGRectMake(knobOffset, 0.0, knobLength, self.updatedScrollerWidth);
frame = ABRectRoundOrigin(CGRectInset(frame, 4, 2));
frame = CGRectIntegral(CGRectInset(frame, 4, 2));
}

[TUIView setAnimationsEnabled:NO block:^{
Expand All @@ -189,11 +195,8 @@ - (void)_updateKnob {
}

- (void)drawRect:(CGRect)rect {
if(!self.expanded) {
self.knob.layer.borderWidth = 1.0f;
if(!self.expanded || ![TUIScrollView requiresExpandingScrollers]) {
return;
} else if([TUIScrollView requiresExpandingScrollers]) {
self.knob.layer.borderWidth = 0.0f;
}

// TUIScrollViewIndicatorStyleLight draws a dark track underneath,
Expand Down Expand Up @@ -244,15 +247,15 @@ - (void)setScrollIndicatorStyle:(TUIScrollViewIndicatorStyle)style {
switch(style) {
case TUIScrollViewIndicatorStyleLight:
self.knob.backgroundColor = [NSColor colorWithCalibratedWhite:1.0 alpha:1.0];
self.knob.layer.borderColor = [NSColor colorWithCalibratedWhite:0.15 alpha:0.25].tui_CGColor;
self.knob.layer.shadowColor = [NSColor colorWithCalibratedWhite:0.5 alpha:1.0].tui_CGColor;
break;
case TUIScrollViewIndicatorStyleDark:
self.knob.backgroundColor = [NSColor colorWithCalibratedWhite:0.0 alpha:1.0];
self.knob.layer.borderColor = [NSColor colorWithCalibratedWhite:0.90 alpha:0.25].tui_CGColor;
self.knob.layer.shadowColor = [NSColor colorWithCalibratedWhite:0.5 alpha:1.0].tui_CGColor;
break;
default:
self.knob.backgroundColor = [NSColor colorWithCalibratedWhite:0.0 alpha:1.0];
self.knob.layer.borderColor = [NSColor colorWithCalibratedWhite:0.5 alpha:1.0].tui_CGColor;
self.knob.layer.shadowColor = [NSColor colorWithCalibratedWhite:1.0 alpha:1.0].tui_CGColor;
break;
}

Expand Down

0 comments on commit c3edfa0

Please sign in to comment.