UIKit.如何设置透明色? [英] UIKit. How to set Transparent color?
问题描述
是否可以将UIImage的任何颜色(或其CALayer内容)设置为透明颜色?
Is there any way to set any color of UIImage (or it CALayer content) as transparent color?
我不能使用具有内置透明度的单个图像资源(PNG文件).
I cannot use single image resource(PNG file) with built-in transparency.
我需要通过在第二层上覆盖特定颜色的第二层来隐藏第一层的某些区域.因此,在组装图像之前,需要将此特定颜色设置为透明颜色".
I need to hide some area from first Layer by overlaying second Layer with specific color at that place. So I need to set this specific color as "transparent color" before assembled image drawing.
我需要隐藏的图像区域就像背景-即特定的颜色将从图像边界到整个周边开始.
Image area I need to hide is like background - i.e. specific color will be started from image borders through whole perimeter.
推荐答案
听起来像您需要使用CGImageCreateWithMaskingColors.我建议阅读位图图像和图像蒙版" 部分,并检查一些示例代码.它比您的普通Cocoa代码略低一些,但并不难实现.
Sounds like you need to use CGImageCreateWithMaskingColors. I recommend reading the "Bitmap Images and Image Masks" part of the Quartz Programming Guide, and check some example code. It's slightly more low-level than your average Cocoa code, but not very hard to accomplish.
这篇关于UIKit.如何设置透明色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!