Objectice C, clear background on gauge


#1

Hi there,

I’m trying to set the background of a radial guage to clear, however setting gauge.style.innerBackgroundColor (and outerBackgroundColor) to [UIColor clearColor] produces a grey background.

Im trying to preserver the needle, knob, and axis (i.e., ticks and marks) while providing my own background image below the gauge, such that the all elements, other than the background image, are preserved.  Cant seem to figure this one out,so any help or advice is appreciated!

I’ve been trying to hack around it by copying the CALayer, but its getting ugly. there has to be an easier way!  Alternatively, if I cant change the backgroudn image, am I able to change the way in which the gradiant between innet and outer radius is applied?  Id like the transition  to start further out from the center.

Thanks!


#2

Ive come back to this again, and made a little bit of progress. To get around the grey gradient I add the gauge to my own view, then copy all of the sublayers to my own view, which copies the ticks and labels, then I add the needle and hide the original gauge. The issue I seem to have now is that I cannot seem to place anyview ontop of the needle (or its knob), for instance adding another subview and calling bringSubviewToFront on it still places it behind the needles knob.  I’m trying to place a label with the current value of the gauge over the knob.

Any idea as to what Im missing?

for(int i = 0; i < self.gauge.layer.sublayers.count; i++){
      [self.layer addSublayer:[self.gauge.layer.sublayers objectAtIndex:i]];
 }
 self.gauge.hidden = YES;
 [self addSubview:self.gauge.needle];

#3

setting my other layers zPosition to MAXFLOAT allows it to cover the needles knob.  Doesnt really seem like a Shinobi issue, likely just ignorance on my behalf!


#4

Hi AEB,

Sounds like you’ve made progress on this.

I’d just like to add that I managed to make the background of the gauge transparent, leaving just the foreground elements by taking our GettingStarted sample and doing the following:

gauge.style.outerBackgroundColor = [UIColor clearColor];
gauge.style.innerBackgroundColor = [UIColor clearColor];
    
gauge.style.glassColor = [UIColor clearColor];
    
gauge.style.bevelPrimaryColor = [UIColor clearColor];
gauge.style.bevelSecondaryColor = [UIColor clearColor];

(Pretty much just setting all the non-UI elements’ colours to clear!).

Thanks,

Sam