我有一张图片,我用另一张图片蒙版来制作形状。
我只是想改变遮罩图像的视图背景颜色。
我使用[UIColor colorWithPatternImage:maskedImage];
但它不起作用。
请告诉我如何在一个图像中合并或创建遮罩2图像,以便colorWithPatternImage
将工作。
UIImage *originalImage = [UIImage imageNamed:@"original.png"]; //my background image
UIImage *maskedImage = [UIImage imageNamed:@"maskedImage.png"]; //my masked image
CGSize newSize = CGSizeMake(width, height);
UIGraphicsBeginImageContext( newSize );
[originalImage drawInRect:CGRectMake(0,0,newSize.width,newSize.height)];
[maskedImage drawInRect:CGRectMake(0,0,newSize.width,newSize.height) blendMode:kCGBlendModeNormal alpha:0.6];
UIImage *newMaskedBackGroundImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
则使用这个newMaskedBackGroundImage,例:[UIColor colorWithPatternImage:newMaskedBackGroundImage];
是否为
赋值 [UIColor colorWithPatternImage:maskedImage];
吗?像…
self.maskedView.backgroundColor = [UIColor colorWithPatternImage:maskedImage];