在图像 IOS 中设置透明度

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11825152/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 19:36:12  来源:igfitidea点击:

Set transparency in image IOS

iphoneobjective-ciosxcode

提问by Feroz

I have a table view, I have addeed image as subview for header, but that image is shown with bagckground white color,how to set transparency for image.

我有一个表视图,我已经添加了图像作为标题的子视图,但是该图像以 bagckground 白色显示,如何设置图像的透明度。

TIA

TIA

回答by superGokuN

For this you have to set alpha of your UIImageView

为此,您必须设置 UIImageView 的 alpha

Your_ImageView.alpha = 0.6;

You can also do it in your xib file

您也可以在您的 xib 文件中执行此操作

回答by Hermann Klecker

Assuming the name of your view is myTransparentSubView:

假设您的视图名称是 myTransparentSubView:

[myTransparentSubView setBackgroundColor:[UIColor clearColor]];

If you are using the Interface Builder then set the background Color property accordingly within IB.

如果您使用的是 Interface Builder,则在 IB 中相应地设置背景颜色属性。

回答by James

The simplest solution is to infact to create an image with a transparent background, however, you can use an Image Maskto get the desired effect.

最简单的解决方案实际上是创建一个具有透明背景的图像,但是,您可以使用图像蒙版来获得所需的效果。

There is already an example of this here.

已经有一个这样的例子在这里

回答by Kamal Abuqaaud

Use image Preview in MAC

在 MAC 中使用图像预览

Start with a png file.

从一个 png 文件开始。

You have to go to View > Show Edit Toolbar.

您必须转到“查看”>“显示编辑工具栏”。

Then widen the window so that you can see all of the icons.

然后加宽窗口,以便您可以看到所有图标。

Then click the icon that looks like a magic wand.

然后单击看起来像魔术棒的图标。

And then click and drag on the color you want to erase.

然后单击并拖动要擦除的颜色。