@@ -60,7 +60,6 @@ - (instancetype)initWithFrame:(CGRect)frame {
60
60
if ((self = [super initWithFrame: frame])) {
61
61
self.autoresizingMask = UIViewAutoresizingFlexibleWidth;
62
62
self.backgroundColor = kWhiteBackgroundColorDefault ;
63
- self.style = BITAppStoreHeaderStyleDefault;
64
63
}
65
64
return self;
66
65
}
@@ -70,25 +69,14 @@ - (instancetype)initWithFrame:(CGRect)frame {
70
69
71
70
- (void )drawRect : (CGRect )rect {
72
71
CGRect bounds = self.bounds ;
73
- CGContextRef context = UIGraphicsGetCurrentContext ();
74
-
75
- if (self.style == BITAppStoreHeaderStyleDefault) {
76
- // draw the gradient
77
- NSArray *colors = [NSArray arrayWithObjects: (id )kDarkGrayColor .CGColor , (id )kLightGrayColor .CGColor , nil ];
78
- CGGradientRef gradient = CGGradientCreateWithColors (CGColorGetColorSpace ((__bridge CGColorRef )[colors objectAtIndex: 0 ]), (__bridge CFArrayRef )colors, (CGFloat [2 ]){0 , 1 });
79
- CGPoint top = CGPointMake (CGRectGetMidX (bounds), bounds.size .height - 3 );
80
- CGPoint bottom = CGPointMake (CGRectGetMidX (bounds), CGRectGetMaxY (bounds));
81
- CGContextDrawLinearGradient (context, gradient, top, bottom, 0 );
82
- CGGradientRelease (gradient);
83
- } else {
84
- // draw the line
85
- CGContextRef ctx = UIGraphicsGetCurrentContext ();
86
- CGContextSetLineWidth (ctx, 1.0 );
87
- CGContextSetStrokeColorWithColor (ctx, kDarkGrayColor .CGColor );
88
- CGContextMoveToPoint (ctx, 0 , CGRectGetMaxY (bounds));
89
- CGContextAddLineToPoint ( ctx, CGRectGetMaxX (bounds), CGRectGetMaxY (bounds));
90
- CGContextStrokePath (ctx);
91
- }
72
+
73
+ // draw the line
74
+ CGContextRef ctx = UIGraphicsGetCurrentContext ();
75
+ CGContextSetLineWidth (ctx, 1.0 );
76
+ CGContextSetStrokeColorWithColor (ctx, kDarkGrayColor .CGColor );
77
+ CGContextMoveToPoint (ctx, 0 , CGRectGetMaxY (bounds));
78
+ CGContextAddLineToPoint ( ctx, CGRectGetMaxX (bounds), CGRectGetMaxY (bounds));
79
+ CGContextStrokePath (ctx);
92
80
93
81
// icon
94
82
[_iconImage drawAtPoint: CGPointMake (kImageLeftMargin , kImageTopMargin )];
@@ -98,8 +86,7 @@ - (void)drawRect:(CGRect)rect {
98
86
99
87
100
88
- (void )layoutSubviews {
101
- if (self.style == BITAppStoreHeaderStyleOS7)
102
- self.backgroundColor = kWhiteBackgroundColorOS7 ;
89
+ self.backgroundColor = kWhiteBackgroundColorOS7 ;
103
90
104
91
[super layoutSubviews ];
105
92
@@ -151,10 +138,7 @@ - (void)setIconImage:(UIImage *)anIconImage {
151
138
152
139
// scale, make borders and reflection
153
140
_iconImage = bit_imageToFitSize (anIconImage, CGSizeMake (kImageHeight , kImageHeight ), YES );
154
- CGFloat radius = kImageBorderRadius ;
155
- if (self.style == BITAppStoreHeaderStyleOS7)
156
- radius = kImageBorderRadiusiOS7 ;
157
- _iconImage = bit_roundedCornerImage (_iconImage, radius, 0.0 );
141
+ _iconImage = bit_roundedCornerImage (_iconImage, kImageBorderRadiusiOS7 , 0.0 );
158
142
159
143
[self setNeedsDisplay ];
160
144
}
0 commit comments