** 修改图片透明度 <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的 背景图片的透明度**
网友评论