@@ -33,25 +33,12 @@ - (id)initWithFrame:(CGRect)frame
3333 if (self) {
3434 // Initialization code
3535
36- if (OSVersionIsAtLeastiOS7 ()){
37- [self setBackgroundColor: [UIColor colorWithRed: 110 ./255.0
38- green: 113.0 /255.0
39- blue: 115.0 /255.0
40- alpha: 1.0 ]];
41- }
42- else {
43- [self setBackgroundColor: [UIColor colorWithRed: 77.0 /255.0
44- green: 79.0 /255.0
45- blue: 80.0 /255.0
46- alpha: 1.0 ]];
47- }
36+ [self setBackgroundColor: [UIColor colorWithRed: 110 ./255.0
37+ green: 113.0 /255.0
38+ blue: 115.0 /255.0
39+ alpha: 1.0 ]];
4840
49- if (OSVersionIsAtLeastiOS7 ()){
50- _label = [[UILabel alloc ] initWithFrame: CGRectMake (15 , CGRectGetMaxY (self .bounds)-28 ,CGRectGetWidth (self .bounds)-30 , 22 )];
51- }
52- else {
53- _label = [[UILabel alloc ] initWithFrame: CGRectInset (self .bounds, 10.0 , 2.0 )];
54- }
41+ _label = [[UILabel alloc ] initWithFrame: CGRectMake (15 , CGRectGetMaxY (self .bounds)-28 ,CGRectGetWidth (self .bounds)-30 , 22 )];
5542
5643
5744 if ([[UIFont class ] respondsToSelector: @selector (preferredFontForTextStyle: )]){
@@ -66,10 +53,6 @@ - (id)initWithFrame:(CGRect)frame
6653 green: 206.0 /255.0
6754 blue: 209.0 /255.0
6855 alpha: 1.0 ]];
69- if (OSVersionIsAtLeastiOS7 () == NO ){
70- [self .label setShadowOffset: CGSizeMake (0 , 1 )];
71- [self .label setShadowColor: [[UIColor blackColor ] colorWithAlphaComponent: .5 ]];
72- }
7356 [self .label setAutoresizingMask: UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleTopMargin];
7457 [self addSubview: self .label];
7558 [self setClipsToBounds: NO ];
@@ -84,79 +67,20 @@ -(void)setTitle:(NSString *)title{
8467
8568-(void )drawRect : (CGRect)rect {
8669 // // General Declarations
87- if (OSVersionIsAtLeastiOS7 ()== NO ){
88- CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB ();
89- CGContextRef context = UIGraphicsGetCurrentContext ();
90-
91- // // Color Declarations
92- UIColor* color = [UIColor colorWithRed: 0.373 green: 0.388 blue: 0.404 alpha: 1 ];
93- UIColor* color2 = [UIColor colorWithRed: 0.216 green: 0.231 blue: 0.243 alpha: 1 ];
94- UIColor* color3 = [UIColor colorWithRed: 0.451 green: 0.463 blue: 0.475 alpha: 1 ];
95- UIColor* color4 = [UIColor colorWithRed: 0.184 green: 0.2 blue: 0.212 alpha: 1 ];
96- UIColor* fillColor2 = [UIColor colorWithRed: 0.373 green: 0.388 blue: 0.404 alpha: 0 ];
97-
98- // // Gradient Declarations
99- NSArray * gradient2Colors = [NSArray arrayWithObjects:
100- (id )color.CGColor,
101- (id )fillColor2.CGColor, nil ];
102- CGFloat gradient2Locations[] = {0 , 1 };
103- CGGradientRef gradient2 = CGGradientCreateWithColors (colorSpace, (__bridge CFArrayRef)gradient2Colors, gradient2Locations);
104-
105- // // Frames
106- CGRect frame = CGRectMake (0 , -1 , CGRectGetWidth (self.bounds ), CGRectGetHeight (self.bounds )+1 );
107-
108-
109- // // Fill Drawing
110- CGRect fillRect = CGRectMake (CGRectGetMinX (frame), CGRectGetMinY (frame), CGRectGetWidth (frame), CGRectGetHeight (frame) - 1 );
111- UIBezierPath* fillPath = [UIBezierPath bezierPathWithRect: fillRect];
112- CGContextSaveGState (context);
113- [fillPath addClip ];
114- CGContextDrawLinearGradient (context, gradient2,
115- CGPointMake (CGRectGetMidX (fillRect), CGRectGetMinY (fillRect)),
116- CGPointMake (CGRectGetMidX (fillRect), CGRectGetMaxY (fillRect)),
117- 0 );
118- CGContextRestoreGState (context);
119-
120-
121- // // TopStroke Drawing
122- UIBezierPath* topStrokePath = [UIBezierPath bezierPathWithRect: CGRectMake (CGRectGetMinX (frame), CGRectGetMinY (frame), CGRectGetWidth (frame), 1 )];
123- [color4 setFill ];
124- [topStrokePath fill ];
125-
126-
127- // // Highlight Drawing
128- UIBezierPath* highlightPath = [UIBezierPath bezierPathWithRect: CGRectMake (CGRectGetMinX (frame), CGRectGetMinY (frame) + 1 , CGRectGetWidth (frame), 1 )];
129- [color3 setFill ];
130- [highlightPath fill ];
131-
132-
133- // // BottomStroke Drawing
134- UIBezierPath* bottomStrokePath = [UIBezierPath bezierPathWithRect: CGRectMake (CGRectGetMinX (frame), CGRectGetMinY (frame) + CGRectGetHeight (frame) - 1 , CGRectGetWidth (frame), 1 )];
135- [color2 setFill ];
136- [bottomStrokePath fill ];
137-
138-
139- // // Cleanup
140- CGGradientRelease (gradient2);
141- CGColorSpaceRelease (colorSpace);
142-
143- }
144- else {
145- CGContextRef context = UIGraphicsGetCurrentContext ();
146- UIColor * lineColor = [UIColor colorWithRed: 94.0 /255.0
147- green: 97.0 /255.0
148- blue: 99.0 /255.0
149- alpha: 1.0 ];
150- CGContextSetStrokeColorWithColor (context, lineColor.CGColor );
151-
152- CGContextSetLineWidth (context, 1.0 );
153-
154- CGContextMoveToPoint (context, CGRectGetMinX (self.bounds ), CGRectGetMaxY (self.bounds )-.5 ); // start at this point
155-
156- CGContextAddLineToPoint (context, CGRectGetMaxX (self.bounds ), CGRectGetMaxY (self.bounds )-.5 ); // draw to this point
157-
158- CGContextStrokePath (context);
159- }
70+ CGContextRef context = UIGraphicsGetCurrentContext ();
71+ UIColor * lineColor = [UIColor colorWithRed: 94.0 /255.0
72+ green: 97.0 /255.0
73+ blue: 99.0 /255.0
74+ alpha: 1.0 ];
75+ CGContextSetStrokeColorWithColor (context, lineColor.CGColor );
76+
77+ CGContextSetLineWidth (context, 1.0 );
78+
79+ CGContextMoveToPoint (context, CGRectGetMinX (self.bounds ), CGRectGetMaxY (self.bounds )-.5 ); // start at this point
80+
81+ CGContextAddLineToPoint (context, CGRectGetMaxX (self.bounds ), CGRectGetMaxY (self.bounds )-.5 ); // draw to this point
82+
83+ CGContextStrokePath (context);
16084}
16185
16286@end
0 commit comments