You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have been struggling for a few days on this aspect, creating a background image using CALayer. The aim is to have a coloured background behind a combined chart view that I am working on which populates the data series.
Create the view that matches the chart's layout, idea being, is that we can add the subview to the chart when drawing is done.
The drawing background using layers x times over within the loop is performed
for (int i = 0; i < portionsCount; i++){
UIColor *selectedColor = ((i % 2) == 0) ? shadeOfGray : shadeOfBlue;
CALayer *subLayer = [CALayerlayer];
subLayer.backgroundColor = selectedColor.CGColor;
/* the positioning arrangement of layer is calculated */
subLayer.opacity = 0.5f;
subLayer.zPosition = -1 - i;
[layer addSublayer:sublayer];
}
The layer gets added into the view
[uiVw.layer addSublayer:layer];
Finally, the view gets added to the combo chart view
[self.comboChartView addSubview:uiVw];
FWIW, the background looks like a chunky bar chart, (its more of a alternating colors to identify the range where the pertinent data fell on a particular series).
What was expected to happen was the background, get rendered beneath the combo chart. Instead I get the background obscuring the chart itself, despite having the zPosition to be in negative.
Any ideas?
The text was updated successfully, but these errors were encountered:
The zPosition means something entirely different than z-index. It's actually the rotation on the z axis.
You have to actually put the layer behind the chart's layer, which means having the correct order in the layers array.
Then set backgroundColor on the chart's view to transparent and opaque to NO.
Hi,
I have been struggling for a few days on this aspect, creating a background image using CALayer. The aim is to have a coloured background behind a combined chart view that I am working on which populates the data series.
Create the view that matches the chart's layout, idea being, is that we can add the subview to the chart when drawing is done.
Create a layer, to do the drawing operations on it.
The drawing background using layers x times over within the loop is performed
The layer gets added into the view
[uiVw.layer addSublayer:layer];
Finally, the view gets added to the combo chart view
FWIW, the background looks like a chunky bar chart, (its more of a alternating colors to identify the range where the pertinent data fell on a particular series).
What was expected to happen was the background, get rendered beneath the combo chart. Instead I get the background obscuring the chart itself, despite having the
zPosition
to be in negative.Any ideas?
The text was updated successfully, but these errors were encountered: