30
30
#define kDefaultLimitDotRadius 2
31
31
#define kDefaultLimitDotColor [UIColor redColor ]
32
32
33
- #define kDefaultValueFont [UIFont fontWithName: @" HelveticaNeue-CondensedBold" size: 150 ]
33
+ #define kDefaultValueFont [UIFont fontWithName: @" HelveticaNeue-CondensedBold" size: 140 ]
34
34
#define kDefaultValueTextColor [UIColor colorWithWhite: 0.1 alpha: 1 ]
35
+ #define kDefaultMinMaxValueFont [UIFont fontWithName: @" HelveticaNeue" size: 12 ]
36
+ #define kDefaultMinMaxValueTextColor [UIColor colorWithWhite: 0.3 alpha: 1 ]
35
37
36
38
#define kDefaultUnitOfMeasurement @" km/h"
37
39
#define kDefaultUnitOfMeasurementFont [UIFont fontWithName: @" HelveticaNeue-CondensedBold" size: 16 ]
@@ -48,6 +50,8 @@ @interface LMGaugeView ()
48
50
@property (nonatomic , strong ) CAShapeLayer *progressLayer;
49
51
@property (nonatomic , strong ) UILabel *valueLabel;
50
52
@property (nonatomic , strong ) UILabel *unitOfMeasurementLabel;
53
+ @property (nonatomic , strong ) UILabel *minValueLabel;
54
+ @property (nonatomic , strong ) UILabel *maxValueLabel;
51
55
52
56
@end
53
57
@@ -111,6 +115,9 @@ - (void)initialize
111
115
// Value Text
112
116
_valueFont = kDefaultValueFont ;
113
117
_valueTextColor = kDefaultValueTextColor ;
118
+ _showMinMaxValue = YES ;
119
+ _minMaxValueFont = kDefaultMinMaxValueFont ;
120
+ _minMaxValueTextColor = kDefaultMinMaxValueTextColor ;
114
121
115
122
// Unit Of Measurement
116
123
_showUnitOfMeasurement = YES ;
@@ -261,6 +268,44 @@ - (void)drawRect:(CGRect)rect
261
268
self.valueLabel .frame = CGRectInset (self.progressLayer .frame , insetX, insetX);
262
269
self.valueLabel .frame = CGRectOffset (self.valueLabel .frame , 0 , self.showUnitOfMeasurement ? -self.divisionsPadding /2 : 0 );
263
270
271
+ /* !
272
+ * Min Value Label
273
+ */
274
+ if (!self.minValueLabel )
275
+ {
276
+ self.minValueLabel = [[UILabel alloc ] init ];
277
+ self.minValueLabel .backgroundColor = [UIColor clearColor ];
278
+ self.minValueLabel .textAlignment = NSTextAlignmentLeft;
279
+ self.minValueLabel .adjustsFontSizeToFitWidth = YES ;
280
+ [self addSubview: self .minValueLabel];
281
+ }
282
+ self.minValueLabel .text = [NSString stringWithFormat: @" %0.f " , self .minValue];
283
+ self.minValueLabel .font = self.minMaxValueFont ;
284
+ self.minValueLabel .minimumScaleFactor = 10 /self.minValueLabel .font .pointSize ;
285
+ self.minValueLabel .textColor = self.minMaxValueTextColor ;
286
+ self.minValueLabel .hidden = !self.showMinMaxValue ;
287
+ CGPoint minDotCenter = CGPointMake (dotRadius * cos (self.startAngle ) + center.x , dotRadius * sin (self.startAngle ) + center.y );
288
+ self.minValueLabel .frame = CGRectMake (minDotCenter.x + 8 , minDotCenter.y - 20 , 40 , 20 );
289
+
290
+ /* !
291
+ * Max Value Label
292
+ */
293
+ if (!self.maxValueLabel )
294
+ {
295
+ self.maxValueLabel = [[UILabel alloc ] init ];
296
+ self.maxValueLabel .backgroundColor = [UIColor clearColor ];
297
+ self.maxValueLabel .textAlignment = NSTextAlignmentRight;
298
+ self.maxValueLabel .adjustsFontSizeToFitWidth = YES ;
299
+ [self addSubview: self .maxValueLabel];
300
+ }
301
+ self.maxValueLabel .text = [NSString stringWithFormat: @" %0.f " , self .maxValue];
302
+ self.maxValueLabel .font = self.minMaxValueFont ;
303
+ self.maxValueLabel .minimumScaleFactor = 10 /self.maxValueLabel .font .pointSize ;
304
+ self.maxValueLabel .textColor = self.minMaxValueTextColor ;
305
+ self.maxValueLabel .hidden = !self.showMinMaxValue ;
306
+ CGPoint maxDotCenter = CGPointMake (dotRadius * cos (self.endAngle ) + center.x , dotRadius * sin (self.endAngle ) + center.y );
307
+ self.maxValueLabel .frame = CGRectMake (maxDotCenter.x - 8 - 40 , maxDotCenter.y - 20 , 40 , 20 );
308
+
264
309
/* !
265
310
* Unit Of Measurement Label
266
311
*/
@@ -477,6 +522,33 @@ - (void)setValueTextColor:(UIColor *)valueTextColor
477
522
}
478
523
}
479
524
525
+ - (void )setShowMinMaxValue : (BOOL )showMinMaxValue
526
+ {
527
+ if (_showMinMaxValue != showMinMaxValue) {
528
+ _showMinMaxValue = showMinMaxValue;
529
+
530
+ [self setNeedsDisplay ];
531
+ }
532
+ }
533
+
534
+ - (void )setMinMaxValueFont : (UIFont *)minMaxValueFont
535
+ {
536
+ if (_minMaxValueFont != minMaxValueFont) {
537
+ _minMaxValueFont = minMaxValueFont;
538
+
539
+ [self setNeedsDisplay ];
540
+ }
541
+ }
542
+
543
+ - (void )setMinMaxValueTextColor : (UIColor *)minMaxValueTextColor
544
+ {
545
+ if (_minMaxValueTextColor != minMaxValueTextColor) {
546
+ _minMaxValueTextColor = minMaxValueTextColor;
547
+
548
+ [self setNeedsDisplay ];
549
+ }
550
+ }
551
+
480
552
- (void )setShowUnitOfMeasurement : (BOOL )showUnitOfMeasurement
481
553
{
482
554
if (_showUnitOfMeasurement != showUnitOfMeasurement) {
0 commit comments