zoukankan      html  css  js  c++  java
  • iOS 设置图片的透明度

    /**
     *  设置图片透明度
     * @param alpha 透明度
     * @param image 图片
     */
    -(UIImage *)imageByApplyingAlpha:(CGFloat )alpha  image:(UIImage*)image
    {
        UIGraphicsBeginImageContextWithOptions(image.size, NO, 0.0f);
        
        CGContextRef ctx = UIGraphicsGetCurrentContext();
        
        CGRect area = CGRectMake(0, 0, image.size.width, image.size.height);
        
        CGContextScaleCTM(ctx, 1, -1);
        
        CGContextTranslateCTM(ctx, 0, -area.size.height);
        
        CGContextSetBlendMode(ctx, kCGBlendModeMultiply);
        
        
        CGContextSetAlpha(ctx, alpha);
        
        
        
        CGContextDrawImage(ctx, area, image.CGImage);
        
        
        
        UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
        
        
        
        
        UIGraphicsEndImageContext();
        
        
        
        return newImage;
        
    }
    
  • 相关阅读:
    计算机网络 其他1
    C++ part9
    C++ part8
    操作系统 part5
    C++ part7
    MyXls导出Excel的各种设置
    C# excel操作
    Castle
    C# Keycode对照表
    IEnumerable.Select和SelectMany的区别
  • 原文地址:https://www.cnblogs.com/boyuanmeng/p/4370957.html
Copyright © 2011-2022 走看看