I am configuring my BEMSimpleLineGraph and have been able to do so successfully except for the linear gradient shading. After referencing this code in the provided example Obj-C project
CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB();
size_t num_locations = 2;
CGFloat locations[2] = { 0.0, 1.0 };
CGFloat components[8] = {
1.0, 1.0, 1.0, 1.0,
1.0, 1.0, 1.0, 0.0
};
self.myGraph.gradientBottom = CGGradientCreateWithColorComponents(colorspace, components, locations, num_locations);
and transcribing it to this in Swift:
let colorspace:CGColorSpaceRef = CGColorSpaceCreateDeviceRGB()
let num_locations:size_t = 2
var locations: [CGFloat] = [0.0, 1.0]
var components: [CGFloat] = [
1.0, 1.0, 1.0, 1.0,
1.0, 1.0, 1.0, 0.0
]
self.myGraph.gradientBottom = CGGradientCreateWithColorComponents(colorspace, components, locations, num_locations)
everything builds correctly but throws up the EXC_BAD_ACCESS memory error in the BEMLine.m file included, stopping at this line
CGContextDrawLinearGradient(ctx, self.bottomGradient, CGPointZero, CGPointMake(0, CGRectGetMaxY(fillBottom.bounds)), 0);
I've included the obj-c bridging header, added CoreGraphics framework, enabled bottom color in the attributes pane of the respective ViewController in Storyboard, referenced Apple's Development pages to ensure correct data types of all the parameters, but am still coming up dry. In checking for error similarities, I have also realized that the same error comes up with trying to draw the top linear gradient as well. The error seems to lie in the Obj-C code trying to draw the gradient, but again I'm at a loss of what to do.