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.

enter image description here

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: enter image description here

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

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -