0

如何通过仅更改一张图像的 alfa 来混合两张图像,使上面的图像稍微透明,并且上面的图像将显示为在背景图像上绘制的那样。

4

1 回答 1

0

您可以通过 imageView alpha 属性来完成

imageView.alpha = 0.0f;

详细代码:

   UIImage *bottomImage = [UIImage imageNamed:@"bottomImage.png"];
    UIImage *topImage = [UIImage imageNamed:@"topImage.png"];

    CGSize newSize = CGSizeMake(width, height);
    UIGraphicsBeginImageContext( newSize );

    // Use existing opacity as is
    [bottomImage drawInRect:CGRectMake(0,0,newSize.width,newSize.height)];
    // Apply supplied opacity
    [topImage drawInRect:CGRectMake(0,0,newSize.width,newSize.height) blendMode:kCGBlendModeNormal alpha:0.8];

    UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

在此处查看更多详细信息

于 2012-09-21T09:19:09.770 回答