CGRect frame = _entranceFunViewController.view.frame;
backgroundImageView = [[UIImageViewalloc]initWithFrame:frame];
UIGraphicsBeginImageContext(backgroundImageView.frame.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGColorSpaceRef rgb = CGColorSpaceCreateDeviceRGB();
CGContextScaleCTM(context, frame.size.width , frame.size.height);
CGFloat colors[] =
{
253.0/255.0, 163.0/255.0, 87.0/255.0, 1.0,
253.0/255.0, 163.0/255.0, 87.0/255.0, 0.0,
};
CGGradientRef backGradient = CGGradientCreateWithColorComponents
(rgb, colors, NULL, sizeof(colors)/(sizeof(colors[0])*4));
CGColorSpaceRelease(rgb);
CGContextDrawLinearGradient(context,
backGradient,
CGPointMake(0.5, 0), CGPointMake(0.5, 1),
kCGGradientDrawsBeforeStartLocation);
backgroundImageView.image = UIGraphicsGetImageFromCurrentImageContext();
②上部发散球效果
//球形扩散图
clearCircleImageView = [[UIImageViewalloc]initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)];
UIGraphicsBeginImageContext(clearCircleImageView.frame.size);
CGContextRef clearCircleContext = UIGraphicsGetCurrentContext();
CGColorSpaceRef clearCircleRGB = CGColorSpaceCreateDeviceRGB();
CGContextRotateCTM(context, -360.0 * M_PI/180.0);
CGFloat clearCircleColors[] =
{
253.0/255.0, 163.0/255.0, 87.0/255.0, 1.0,
253.0/255.0, 163.0/255.0, 87.0/255.0, 0.0,
};
CGGradientRef clearCircleGradient =CGGradientCreateWithColorComponents
(clearCircleRGB, clearCircleColors, NULL,sizeof(colors)/(sizeof(colors[0])*4));
CGColorSpaceRelease(rgb);
CGContextDrawRadialGradient(clearCircleContext,
clearCircleGradient, CGPointMake(160, 160), 0,
CGPointMake(160, 160), 160,kCGGradientDrawsBeforeStartLocation);
clearCircleImageView.image = UIGraphicsGetImageFromCurrentImageContext();
[backgroundImageView addSubview:clearCircleImageView];
CGGradientRelease(clearCircleGradient);