修改图片透明度

2016-11-17  本文已影响8人  路这么长

** 修改图片透明度 <h1>**

** 参数 1:修改的透明度 参数2:需要修改的图片 <h3>**

-(UIImage*)imageByApplyingAlpha:(CGFloat)alphaimage:(UIImage*)image
{
UIGraphicsBeginImageContextWithOptions(image.size,NO,0.0f);
CGContextRefctx =UIGraphicsGetCurrentContext();
CGRectarea =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();
returnnewImage;
}

** 用此方法可以设置 navigationBar的 背景图片的透明度**

上一篇 下一篇

猜你喜欢

热点阅读