xcode iphone:如何在 UIVIEW 上制作透明蒙版
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6055382/
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
iphone: How to make a Transparency mask over the UIVIEW
提问by Xcobe
Dears, I'm trying to create a mask over the UIView. I tried adding a View with Alpha lower than 1, the problem was, all the alpha of the controls like images, buttons on this View has been set to same value.
亲爱的,我正在尝试在 UIView 上创建一个蒙版。我尝试添加一个 Alpha 低于 1 的视图,问题是,该视图上的所有控件(如图像、按钮)的 Alpha 都设置为相同的值。
How can I only change the background transparent but don't impact other controls?
如何只更改背景透明但不影响其他控件?
I also tried UIImageView, but seems UIImageView couldn't attach other controls
我也尝试过 UIImageView,但似乎 UIImageView 无法附加其他控件
采纳答案by Nick Weaver
Have a look at iPhone - Create a semi transparent rectangle with textI think you are having the same problem.
看看iPhone - 创建一个带有文本的半透明矩形我认为您遇到了同样的问题。
回答by pradeepa
try this
尝试这个
view.backGroundColor=[[UIColor alloc] initWithRed:0.0 green:0.0 blue:0.0 alpha:0.7];
回答by Ravena
The UIImageView (with any alpha) should be the first control in your view controller. In outline window it must be at the top of controls list inside view container.
UIImageView(带有任何 alpha)应该是您的视图控制器中的第一个控件。在大纲窗口中,它必须位于视图容器内的控件列表的顶部。
回答by Imran Raheem
Try to set background color of your UIView like this:
尝试像这样设置 UIView 的背景颜色:
yourView.backgroundColor = [UIColor colorWithWhite:0.75f alpha:1.0f];
回答by Hisenberg
HI..
你好..
I've done a the same couple of times...what i did was..
我做了同样的几次......我所做的是......
I used a UIView
and then added a UIImageView
on it..
我用了一个UIView
,然后UIImageView
在它上面加了一个..
now add the subviews to the UIView
..not on the image view..
现在将子视图添加到UIView
..not 在图像视图上..
so now decreasing the alpha of the imageview won't affect the alpha of the subviews added on UIView
.. ;)
所以现在降低 imageview 的 alpha 不会影响添加到UIView
..的子视图的 alpha ;)
Hope it helps. .
希望能帮助到你。.