简体   繁体   English

如何在iOS的C#中为固定背景图像上的颜色设置颜色的透明度级别?

[英]How to set the transparency level for a color over a fixed background image in C# for iOS?

I would like to have these 2 things in my iOS game: 我想在我的iOS游戏中拥有以下两点:

(A) One background image of a car as the background image of the game. (A)汽车的一个背景图像作为游戏的背景图像。 This background image has the RED color. 该背景图像为红色 (I already know how to do this part A). (我已经知道如何执行A部分)。

(B) Next, I want to draw a GREEN rectangle on the TOP of that background image of the car. (B)接下来,我想在汽车的背景图片的顶部绘制一个绿色矩形。 But, I need to set some level of transparency for that GREEN rectangle so that the GREEN rectangle is 50% clear (or transparent) in order for viewers to be able to see the part of the car behind that GREEN rectangle. 但是,我需要为该GREEN矩形设置一定程度的透明度,以使GREEN矩形具有50%的净度(或透明性),以便观众能够看到该GREEN矩形后面的汽车部分。 This transparency is what I don't know how to implement yet. 这种透明度是我尚不知道如何实现的。

Would you please show me how to write the code for part (B) in C# for iOS ? 您能否告诉我如何在iOS的C#中编写(B)部分的代码?

( I am using C# with Xamarin to write code, and unfortunately, I can't understand Objective-C or Swift .) 我在Xamarin上使用C#编写代码,不幸的是,我听不懂Objective-C或Swift 。)

Thank you very much. 非常感谢你。

很简单,您可以在图像上添加UIView,将其背景颜色设置为绿色,并将其Alpha设置为介于0和1之间的某个值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM