创建渐变颜色
CGGradientRef TableBackgroundGradient()
{
static CGGradientRef layoutGradient = NULL;
if (!layoutGradient)
{
UIColor *contentColorTop = [UIColor colorWithRed:0.90 green:0.92 blue:0.95 alpha:1.0];
UIColor *contentColorBottom = [UIColor colorWithRed:0.70 green:0.72 blue:0.75 alpha:1.0];
CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB();
CGFloat backgroundColorComponents[3][4];
memcpy(
backgroundColorComponents[0],
CGColorGetComponents(contentColorTop.CGColor),
sizeof(CGFloat) * 4);
memcpy(
backgroundColorComponents[1],
CGColorGetComponents(contentColorBottom.CGColor),
sizeof(CGFloat) * 4);
const CGFloat endpointLocations[2] = {0.0, 1.0};
layoutGradient =
CGGradientCreateWithColorComponents(
colorspace,
(const CGFloat *)backgroundColorComponents,
endpointLocations,
2);
CFRelease(colorspace);
}
return layoutGradient;
}