NUCLiOS IGGaugeView: Place Custom Views at Specific Values

Stephen Zaharuk / Tuesday, September 30, 2014

The IGGaugeView is one of our most customizable controls. You can control the placement of pretty much anything that it draws within it. However, you may want to display some custom content on top of the gauge, for specific values. 

Turns out, like everything else in this control, its super easy!

You just need to use the following method:

-(CGPoint)pointForValue:(CGFloat)value atExtent:(CGFloat)extent;

The method takes 2 parameters:

Value: This is the actual value within your gauge you'd like to display. So for example if you have want to display your custom view in the middle of your range, and your min value = 0 and your max value = 100, then you would set the value to be 50.

Extent: This is a value from 1.0 through 0.0.  Where 1 is the outer bounds of the gauge, and 0 is the inner bounds. So, if you wanted to display the custom view near the outside of the gauge, you could set it to value like .9.

The return value of the method, is the point relative to the gauge that meets the passed in criteria. 

We actually use this method heavily within the SBViz application we wrote back in January

Each one of those floating circles is a UILabel that we're positioning over the gauge. 

I hope this was helpful.