zoukankan      html  css  js  c++  java
  • IOS图片的两种处理:加阴影和变灰色

        

    #import <QuartzCore/QuartzCore.h>

        //图片阴影

        UIImageView *img;

        [[img layer] setShadowOffset:CGSizeMake(5, 5)];

        [[img layer] setShadowRadius:6];

        [[img layer] setShadowOpacity:1];

        [[img layer] setShadowColor:[UIColor lightGrayColor].CGColor];


    //变灰色

    -(UIImage*)getGrayImage:(UIImage*)sourceImage

    {

        int width = sourceImage.size.width;

        int height = sourceImage.size.height;

        CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceGray();

        CGContextRef context = CGBitmapContextCreate (nil,width,height,8,0,colorSpace,kCGImageAlphaNone);

        CGColorSpaceRelease(colorSpace);

        

        if (context == NULL) {

            return nil;

        }

        

        CGContextDrawImage(context,CGRectMake(0, 0, width, height), sourceImage.CGImage);

        UIImage *grayImage = [UIImage imageWithCGImage:CGBitmapContextCreateImage(context)];

        CGContextRelease(context);

        

        return grayImage;

    }

  • 相关阅读:
    day3 数据类型
    子查询
    mysql综合练习题
    day5 练习
    月末总结
    Iconfont-阿里巴巴矢量图标库
    vue简介
    Redis简介和数据结构
    浏览器初始化css
    vue脚手架搭建项目初始化
  • 原文地址:https://www.cnblogs.com/JayK/p/3955500.html
Copyright © 2011-2022 走看看