简体   繁体   English

如何在 UI 表格视图后面放置黑色不透明背景?

[英]How do I put a black opaque background behind a UI tableview?

I have a textfield that, when text is entered, pops up into a tableview .我有一个textfield ,当输入文本时,它会弹出到tableview中。 The tableview only takes up the bottom half of the screen, and when the tableview is showing at least one option, I would like to make the rest of the screen an opaque black. tableview只占据屏幕的下半部分,当tableview显示至少一个选项时,我想将屏幕的rest设为不透明的黑色。 (Note, I'm not talking about the color of the tableview itself, but adding a dark tint to the rest of the screen.) The area on top of the tableview also has other elements, so it's not as simple as just changing the background color. (注意,我说的不是tableview本身的颜色,而是给屏幕的rest加一个暗色调。) tableview上方的区域还有其他元素,所以不是简单的改变背景颜色。 Whenever I try to change it from where the tableview is controlled, I end up just changing the background of the tableview itself.每当我尝试从控制tableview的位置更改它时,我最终只是更改了tableview本身的背景。

Here is a visual of something similar to what I'm trying to achieve:这是类似于我要实现的目标的视觉效果:

https://images.app.goo.gl/npAE5ga2kCmQ8E2d7 . https://images.app.goo.gl/npAE5ga2kCmQ8E2d7

Any help would be greatly appreciated!任何帮助将不胜感激!

1) Add your Selection options in new viewController names as optionPopUp(what ever you want). 1)在新的viewController名称中添加您的选择选项作为optionPopUp(无论您想要什么)。

2) set modalpresntationstyle of your new popUp as over current context with transition style as crossdisolve. 2)将新弹出窗口的 modalpresntationstyle 设置为当前上下文,过渡样式为 crossdisolve。

3) set background view color of new popUp viewcontroller with opacity(0.1 or 10%). 3)使用不透明度(0.1 或 10%)设置新弹出视图控制器的背景视图颜色。

**4)**Present you popUp from source view controller ie in didselectrowat method of uitableview delegate **4)**从源视图 controller 向您展示弹出窗口,即在 uitableview 委托的 didselectrowat 方法中

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

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