diff --git a/LMGaugeView.podspec b/LMGaugeView.podspec
index 85a9070..05d1b23 100644
--- a/LMGaugeView.podspec
+++ b/LMGaugeView.podspec
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.name = "LMGaugeView"
- s.version = "1.0.4"
+ s.version = "1.0.5"
s.summary = "LMGaugeView is a simple and customizable gauge control for iOS."
s.homepage = "https://github.com/lminhtm/LMGaugeView"
s.license = 'MIT'
diff --git a/LMGaugeView/LMGaugeView.h b/LMGaugeView/LMGaugeView.h
index e1c57e5..0c916f8 100755
--- a/LMGaugeView/LMGaugeView.h
+++ b/LMGaugeView/LMGaugeView.h
@@ -48,6 +48,11 @@ IB_DESIGNABLE
*/
@property (nonatomic, assign) IBInspectable CGFloat ringThickness;
+/*!
+ * A boolean indicates whether to show ring background.
+ */
+@property (nonatomic, assign) IBInspectable BOOL showRingBackground;
+
/*!
* The background color of the ring.
*/
@@ -138,6 +143,11 @@ IB_DESIGNABLE
*/
@property (nonatomic, strong) IBInspectable UIColor *unitOfMeasurementTextColor;
+/*!
+ * A boolean indicates whether to show decimal value.
+ */
+@property (nonatomic, assign) IBInspectable BOOL decimalFormat;
+
/*!
* The receiver of all gauge view delegate callbacks.
*/
diff --git a/LMGaugeView/LMGaugeView.m b/LMGaugeView/LMGaugeView.m
index 282703c..6201149 100755
--- a/LMGaugeView/LMGaugeView.m
+++ b/LMGaugeView/LMGaugeView.m
@@ -95,6 +95,7 @@ - (void)initialize
_numOfSubDivisions = kDefaultNumOfSubDivisions;
// Ring
+ _showRingBackground = YES;
_ringThickness = kDefaultRingThickness;
_ringBackgroundColor = kDefaultRingBackgroundColor;
@@ -165,11 +166,13 @@ - (void)drawRect:(CGRect)rect
/*!
* Draw the ring background
*/
- CGContextSetLineWidth(context, self.ringThickness);
- CGContextBeginPath(context);
- CGContextAddArc(context, center.x, center.y, ringRadius, 0, M_PI * 2, 0);
- CGContextSetStrokeColorWithColor(context, [self.ringBackgroundColor colorWithAlphaComponent:0.3].CGColor);
- CGContextStrokePath(context);
+ if (self.showRingBackground) {
+ CGContextSetLineWidth(context, self.ringThickness);
+ CGContextBeginPath(context);
+ CGContextAddArc(context, center.x, center.y, ringRadius, 0, M_PI * 2, 0);
+ CGContextSetStrokeColorWithColor(context, [self.ringBackgroundColor colorWithAlphaComponent:0.3].CGColor);
+ CGContextStrokePath(context);
+ }
/*!
* Draw the ring progress background
@@ -264,10 +267,15 @@ - (void)drawRect:(CGRect)rect
self.valueLabel = [[UILabel alloc] init];
self.valueLabel.backgroundColor = [UIColor clearColor];
self.valueLabel.textAlignment = NSTextAlignmentCenter;
- self.valueLabel.text = [NSString stringWithFormat:@"%0.f", self.value];
+ if (self.decimalFormat) {
+ self.valueLabel.text = [NSString stringWithFormat:@"%.1f", self.value];
+ }
+ else {
+ self.valueLabel.text = [NSString stringWithFormat:@"%0.f", self.value];
+ }
self.valueLabel.font = self.valueFont;
self.valueLabel.adjustsFontSizeToFitWidth = YES;
- self.valueLabel.minimumScaleFactor = 10/self.valueLabel.font.pointSize;
+ self.valueLabel.minimumScaleFactor = 0.5;
self.valueLabel.textColor = self.valueTextColor;
[self addSubview:self.valueLabel];
}
@@ -288,7 +296,7 @@ - (void)drawRect:(CGRect)rect
}
self.minValueLabel.text = [NSString stringWithFormat:@"%0.f", self.minValue];
self.minValueLabel.font = self.minMaxValueFont;
- self.minValueLabel.minimumScaleFactor = 10/self.minValueLabel.font.pointSize;
+ self.minValueLabel.minimumScaleFactor = 0.5;
self.minValueLabel.textColor = self.minMaxValueTextColor;
self.minValueLabel.hidden = !self.showMinMaxValue;
CGPoint minDotCenter = CGPointMake(dotRadius * cos(self.startAngle) + center.x, dotRadius * sin(self.startAngle) + center.y);
@@ -307,7 +315,7 @@ - (void)drawRect:(CGRect)rect
}
self.maxValueLabel.text = [NSString stringWithFormat:@"%0.f", self.maxValue];
self.maxValueLabel.font = self.minMaxValueFont;
- self.maxValueLabel.minimumScaleFactor = 10/self.maxValueLabel.font.pointSize;
+ self.maxValueLabel.minimumScaleFactor = 0.5;
self.maxValueLabel.textColor = self.minMaxValueTextColor;
self.maxValueLabel.hidden = !self.showMinMaxValue;
CGPoint maxDotCenter = CGPointMake(dotRadius * cos(self.endAngle) + center.x, dotRadius * sin(self.endAngle) + center.y);
@@ -324,7 +332,7 @@ - (void)drawRect:(CGRect)rect
self.unitOfMeasurementLabel.text = self.unitOfMeasurement;
self.unitOfMeasurementLabel.font = self.unitOfMeasurementFont;
self.unitOfMeasurementLabel.adjustsFontSizeToFitWidth = YES;
- self.unitOfMeasurementLabel.minimumScaleFactor = 10/self.unitOfMeasurementLabel.font.pointSize;
+ self.unitOfMeasurementLabel.minimumScaleFactor = 0.5;
self.unitOfMeasurementLabel.textColor = self.unitOfMeasurementTextColor;
[self addSubview:self.unitOfMeasurementLabel];
self.unitOfMeasurementLabel.hidden = !self.showUnitOfMeasurement;
@@ -367,7 +375,12 @@ - (void)setValue:(CGFloat)value
/*!
* Set text for value label
*/
- self.valueLabel.text = [NSString stringWithFormat:@"%0.f", _value];
+ if (self.decimalFormat) {
+ self.valueLabel.text = [NSString stringWithFormat:@"%.1f", _value];
+ }
+ else {
+ self.valueLabel.text = [NSString stringWithFormat:@"%0.f", _value];
+ }
/*!
* Trigger the stoke animation of ring layer.
@@ -516,7 +529,6 @@ - (void)setValueFont:(UIFont *)valueFont
_valueFont = valueFont;
self.valueLabel.font = _valueFont;
- self.valueLabel.minimumScaleFactor = 10/_valueFont.pointSize;
}
}
@@ -580,7 +592,6 @@ - (void)setUnitOfMeasurementFont:(UIFont *)unitOfMeasurementFont
_unitOfMeasurementFont = unitOfMeasurementFont;
self.unitOfMeasurementLabel.font = _unitOfMeasurementFont;
- self.unitOfMeasurementLabel.minimumScaleFactor = 10/_unitOfMeasurementFont.pointSize;
}
}
diff --git a/LMGaugeViewDemo/LMGaugeViewDemo.xcodeproj/project.xcworkspace/xcuserdata/lminh.xcuserdatad/UserInterfaceState.xcuserstate b/LMGaugeViewDemo/LMGaugeViewDemo.xcodeproj/project.xcworkspace/xcuserdata/lminh.xcuserdatad/UserInterfaceState.xcuserstate
index 7f6c3c1..195d98d 100644
Binary files a/LMGaugeViewDemo/LMGaugeViewDemo.xcodeproj/project.xcworkspace/xcuserdata/lminh.xcuserdatad/UserInterfaceState.xcuserstate and b/LMGaugeViewDemo/LMGaugeViewDemo.xcodeproj/project.xcworkspace/xcuserdata/lminh.xcuserdatad/UserInterfaceState.xcuserstate differ
diff --git a/LMGaugeViewDemo/LMGaugeViewDemo/LMGaugeViewDemo-Info.plist b/LMGaugeViewDemo/LMGaugeViewDemo/LMGaugeViewDemo-Info.plist
index f505ad6..270a655 100755
--- a/LMGaugeViewDemo/LMGaugeViewDemo/LMGaugeViewDemo-Info.plist
+++ b/LMGaugeViewDemo/LMGaugeViewDemo/LMGaugeViewDemo-Info.plist
@@ -17,11 +17,11 @@
CFBundlePackageType
APPL
CFBundleShortVersionString
- 1.0.4
+ 1.0.5
CFBundleSignature
????
CFBundleVersion
- 40
+ 50
LSRequiresIPhoneOS
UILaunchStoryboardName