iOS绘制效果界面

iOS绘制效果界面

 
我们除了平时来扩展单色背景图方式来减小图片,还可以用iOS自带的类库同样能做出好的背景,可以大大缩小软件的大小。下面是做出的效果
iOS绘制效果界面
以3.5寸屏为例,大小可以自己控制
直接贴代码吧:
①底部上下渐变效果背景

    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, NULLsizeof(colors)/(sizeof(colors[0])*4));

    CGColorSpaceRelease(rgb);

    CGContextDrawLinearGradient(context,

                                backGradient,

                                CGPointMake(0.50), CGPointMake(0.51),

                                kCGGradientDrawsBeforeStartLocation);

    backgroundImageView.image = UIGraphicsGetImageFromCurrentImageContext();

②上部发散球效果

 //球形扩散图

    clearCircleImageView = [[UIImageViewalloc]initWithFrame:CGRectMake(00, 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(160160), 0,

                                CGPointMake(160, 160), 160,kCGGradientDrawsBeforeStartLocation);

    clearCircleImageView.image = UIGraphicsGetImageFromCurrentImageContext();

    [backgroundImageView addSubview:clearCircleImageView];

    CGGradientRelease(clearCircleGradient);

简单说,底部绘制一矩形,上端绘制已透明度变化的黄球。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值