forked from soffes/sstoolkit
/
SSGradientView.h
146 lines (110 loc) · 3.37 KB
/
SSGradientView.h
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
//
// SSGradientView.h
// SSToolkit
//
// Created by Sam Soffes on 10/27/09.
// Copyright 2009-2010 Sam Soffes. All rights reserved.
//
// Greatly inspired by BWGradientBox. http://brandonwalkin.com/bwtoolkit
//
/** @brief Simple UIView wrapper for CGGradient.
@section known_bugs Known bugs
@li startColor and endColor must be in the same colorspace. The colorspace
of the first color is used to draw the gradient. If you did a gradient from
white to blue, it would look like a gradient from white to black because the
first color, white, is in the gray color space, not the RGB color space.
If you did it from blue to white, it would look like blue to black because
white in the gray colorspace isn't a valid color in the RGB colorspace (because
there are only 2 components in the gray colorspace and 4 in the RGB colorspace).
Automatic colorspace conversions are planned for the future.
*/
@interface SSGradientView : UIView {
UIColor *_topColor;
UIColor *_bottomColor;
UIColor *_topBorderColor;
UIColor *_bottomBorderColor;
CGFloat _topInsetAlpha;
CGFloat _bottomInsetAlpha;
BOOL _hasTopBorder;
BOOL _hasBottomBorder;
BOOL _showsInsets;
@protected
CGGradientRef _gradient;
}
/**
@brief The top gradient color.
@see defaultTopColor
*/
@property (nonatomic, retain) UIColor *topColor;
/**
@brief The bottom gradient color.
@see defaultBottomColor
*/
@property (nonatomic, retain) UIColor *bottomColor;
/**
@brief The top border color.
@see defaultTopBorderColor
*/
@property (nonatomic, retain) UIColor *topBorderColor;
/**
@brief The bottom border color.
@see defaultBottomColor
*/
@property (nonatomic, retain) UIColor *bottomBorderColor;
/**
@brief The top border inset alpha.
If the value is less than or equal to 0.0, it will not be drawn. The
default 0.3.
@see defaultTopInsetAlpha
*/
@property (nonatomic, assign) CGFloat topInsetAlpha;
/**
@brief The bottom border inset alpha.
If the value is less than or equal to 0.0, it will not be drawn. The
default 0.0.
@see defaultBottomInsetAlpha
*/
@property (nonatomic, assign) CGFloat bottomInsetAlpha;
/**
@brief A Boolean value that determines whether showing the top border is enabled.
*/
@property (nonatomic, assign) BOOL hasTopBorder;
/**
@brief A Boolean value that determines whether showing the bottom border is enabled.
*/
@property (nonatomic, assign) BOOL hasBottomBorder;
/**
@brief A Boolean value that determines whether the border insets are enabled.
*/
@property (nonatomic, assign) BOOL showsInsets;
/**
@brief The default top gradient color.
@return A color with its value set to the default top gradient color.
*/
+ (UIColor *)defaultTopColor;
/**
@brief The default bottom gradient color.
@return A color with its value set to the default bottom gradient color.
*/
+ (UIColor *)defaultBottomColor;
/**
@brief The default top border color.
@return A color with its value set to the default top border color.
*/
+ (UIColor *)defaultTopBorderColor;
/**
@brief The default bottom border color.
@return A color with its value set to the default bottom border color.
*/
+ (UIColor *)defaultBottomBorderColor;
/**
@brief The default top inset alpha.
@return The default top inset alpha.
*/
+ (CGFloat)defaultTopInsetAlpha;
/**
@brief The default bottom inset alpha.
@return The default bottom inset alpha.
*/
+ (CGFloat)defaultBottomInsetAlpha;
@end