-
Notifications
You must be signed in to change notification settings - Fork 2
/
GradientView.m
61 lines (55 loc) · 1.36 KB
/
GradientView.m
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//
// xCode_Keyboard_ShortcutsAppDelegate.h
// xCode Keyboard Shortcuts
//
// Created by Matheus Brum on 18/11/09.
// Copyright __MyCompanyName__ 2009. All rights reserved.
//
#import "GradientView.h"
#import <QuartzCore/QuartzCore.h>
@implementation GradientView
//
// layerClass
//
// returns a CAGradientLayer class as the default layer class for this view
//
+ (Class)layerClass
{
return [CAGradientLayer class];
}
//
// setupGradientLayer
//
// Construct the gradient for either construction method
//
- (void)setupGradientLayer
{
CAGradientLayer *gradientLayer = (CAGradientLayer *)self.layer;
gradientLayer.colors =
[NSArray arrayWithObjects:
(id)[UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1.0].CGColor,
(id)[UIColor colorWithRed:0.85 green:0.85 blue:0.85 alpha:1.0].CGColor,
nil];
self.backgroundColor = [UIColor clearColor];
}
//
// initWithFrame:
//
// Initialise the view.
//
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self)
{
CAGradientLayer *gradientLayer = (CAGradientLayer *)self.layer;
gradientLayer.colors =
[NSArray arrayWithObjects:
(id)[UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1.0].CGColor,
(id)[UIColor colorWithRed:0.95 green:0.95 blue:0.95 alpha:1.0].CGColor,
nil];
self.backgroundColor = [UIColor clearColor];
}
return self;
}
@end