-
Notifications
You must be signed in to change notification settings - Fork 1
/
SPGradientBox.mm
41 lines (28 loc) · 1.35 KB
/
SPGradientBox.mm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#import "SPGradientBox.h"
@implementation SPGradientBox
// ----------------------------------------------------------------------------
- (void) drawRect:(NSRect)rect
// ----------------------------------------------------------------------------
{
NSGradient* gradient = [[NSGradient alloc] initWithStartingColor:[NSColor colorWithCalibratedWhite:0.96f alpha:1.0f] endingColor:[NSColor colorWithCalibratedWhite:0.89f alpha:1.0f]];
[gradient drawInRect:[self bounds] angle:-90];
}
@end
@implementation SPDarkGradientBox
// ----------------------------------------------------------------------------
- (void) drawRect:(NSRect)rect
// ----------------------------------------------------------------------------
{
NSGradient* gradient = [[NSGradient alloc] initWithStartingColor:[NSColor colorWithCalibratedWhite:0.76f alpha:1.0f] endingColor:[NSColor colorWithCalibratedWhite:0.59f alpha:1.0f]];
[gradient drawInRect:[self bounds] angle:-90];
NSColor* darkColor = [NSColor colorWithCalibratedWhite:0.3f alpha:1.0f];
NSRect bounds = [self bounds];
float ypos = bounds.origin.y + bounds.size.height;
[NSBezierPath setDefaultLineWidth:1.0f];
NSBezierPath* path = [NSBezierPath bezierPath];
[path moveToPoint:NSMakePoint(rect.origin.x, ypos)];
[path lineToPoint:NSMakePoint(rect.origin.x + rect.size.width, ypos)];
[darkColor set];
[path stroke];
}
@end