ios - Is it possible to apply a vertical gradient as well as a horizontal gradient fade-out on the sides of a graph? -
is possible apply vertical gradient horizontal gradient fade-out on sides of graph?
here image demonstrates talking about. can see graph in has vertical cptgradient fill areafill.
the code this:
cptgradient *areagradient = [cptgradient gradientwithbeginningcolor:[[cptcolor whitecolor] colorwithalphacomponent:.5f] endingcolor:[[cptcolor whitecolor] colorwithalphacomponent:.1f]]; areagradient.angle = -90.0; cptfill *areagradientfill = [cptfill fillwithgradient:areagradient]; tempplot.areafill = areagradientfill; tempplot.areabasevalue = cptdecimalfromdouble(0.0);
for edges of graph, this:
cptgradient *gradient2 = [[cptgradient alloc] init]; gradient2 = [gradient2 addcolorstop:[cptcolor clearcolor] atposition:0.0]; gradient2 = [gradient2 addcolorstop:[[cptcolor whitecolor] colorwithalphacomponent:.5f] atposition:.05]; gradient2 = [gradient2 addcolorstop:[cptcolor clearcolor] atposition:.05]; gradient2 = [gradient2 addcolorstop:[cptcolor clearcolor] atposition:1.]; gradient2.angle = 180.f; tempplot.areafill2 = [cptfill fillwithgradient:gradient2]; tempplot.areabasevalue2 = cptdecimalfromdouble(0.0);
however, problem doesn't play nicely other gradient:
how can achieve 'fade out' effect on each side of plot?
i ended finding answer. fade on edges of graph, use cagradientlayer mask on host view, self.hostview
of type cptgraphhostingview
cagradientlayer *l = [cagradientlayer layer]; l.frame = self.hostview.bounds; l.colors = @[ (id)[uicolor clearcolor].cgcolor, (id)[uicolor whitecolor].cgcolor, (id)[uicolor whitecolor].cgcolor, (id)[uicolor clearcolor].cgcolor ]; l.locations = @[ @0.f, @0.02f, @0.98f, @1.f ]; l.startpoint = cgpointmake(0.f, 0.5f); l.endpoint = cgpointmake(1.0f, 0.5f); self.hostview.layer.mask = l;
Comments
Post a Comment